# `AshVault.Errors.InvalidScope`
[🔗](https://github.com/jakeschurch/ash_vault/blob/main/lib/ash_vault/errors.ex#L131)

Raised when an `AshVault.Scope` implementation returns something other than a binary.

Scope keys address key material in the provider and are baked into the AAD of every
ciphertext, so they must be stable across processes, releases and OTP upgrades. A
non-binary term is not: `:erlang.term_to_binary/1` is explicitly not stable, and an
encoding change would relocate a tenant's tombstone and key name at once.

The `:scope` field holds a **description** of the offending term, never the term
itself — see `AshVault.Scope.describe/1`. A scope term is usually a tenant, and a
loaded tenant record carries customer PII into every log line and APM trace this error
reaches. The shape is the entire diagnosis.

# `exception`

```elixir
@spec exception(opts :: Keyword.t()) :: %AshVault.Errors.InvalidScope{
  __exception__: true,
  bread_crumbs: term(),
  class: term(),
  field: term(),
  path: term(),
  resource: term(),
  scope: term(),
  scope_module: term(),
  splode: term(),
  stacktrace: term(),
  vars: term()
}
```

Create an `Elixir.AshVault.Errors.InvalidScope` without raising it.

## Keys

- :scope_module
- :scope
- :resource
- :field

---

*Consult [api-reference.md](api-reference.md) for complete listing*
