# Errors

Every vault error is `application/problem+json` with a stable `code`. The CLI prints it as `error: <method> <path>: HTTP <status> <code>: <detail>`, and leaves out the code when the vault sent none. For a `401`, the CLI adds `Mint a new vaults:read token in the portal`. For a `403 insufficient_scope`, it adds `This needs a vaults:admin token: mint one in the portal`.

With `--json`, the CLI prints the error on standard error as an `octet-vault/error/1` object (see [JSON output](/docs/vaults/reference/cli/#json-output)).

## Vault errors

| Status | Code | Cause | What to do |
|---|---|---|---|
| `400` | `owner_signature_invalid` | The recipient key's owner signature does not verify against the vault's owner key | Sign with the vault's current owner key |
| `400` | `challenge_mismatch` | The answer to the registration challenge is wrong | Register again with the right key file |
| `400` | `invalid_public_key`, `invalid_kid` | A malformed key or key ID | Use the CLI's `register` |
| `401` | | No token, an expired or revoked token, or a token for another Octet API | Mint a vault token in the portal (see [Credentials](/docs/vaults/integration/credentials/)) |
| `401` | `delegation_unknown` | The delegation was never registered with this vault | Have the vault owner run `delegation create`, which registers it |
| `401` | `delegation_revoked` | The delegation, or a block in it, is revoked | Ask the vault owner for a new delegation |
| `401` | `delegate_signature` | The request signature is missing or wrong, or the request time is more than 60 seconds off | Pass the auditor key the delegation was made for, and check the machine's clock |
| `401` | `delegate_replay` | A request nonce was reused | Retry. The CLI sends a fresh nonce each time. |
| `403` | `insufficient_scope` | A `vaults:read` token on a route that changes the vault | Use a `vaults:admin` token |
| `403` | `delegation_scope` | The delegation does not allow this route or object | Ask the vault owner to delegate it |
| `404` | `vault_not_enabled` | No vault exists for the token's licence and environment, or the vault is off for this change | Check the token's environment, or ask Octet |
| `404` | `key_not_found` | No such key in this vault | Check the `kid` with `octet-vault --token-file read.token key list` |
| `404` | `grant_unknown` | No grant with that ID for this auditor | Check the `<object-id>:<grant-id>` pair |
| `409` | `key_exists` | That key is already registered | Nothing to do |
| `409` | `key_not_active`, `key_revoked` | The key is not active, or is revoked | Register a new key |
| `409` | `object_held` | The object, or the whole vault, is under a legal hold | Clear the hold first |
| `409` | `object_worm_locked` | A write-once object before its expiry | Wait for its expiry, or destroy its recipient key |
| `409` | `retention_root_pending` | A sampled retention challenge on an object whose retention root is not committed yet. `retention-challenge` reports it as ABSENT, and the result is INCONCLUSIVE, exit code `3`. | Retry after the root is committed, or run `retention-challenge --full --blob <file>` with your copy of the object |
| `410` | `challenge_expired` | The registration challenge was used or is older than 10 minutes | Run `register` again |
| `429` | `retention_challenge_rate_limited` | More than 60 retention challenges for the licence in this clock hour, across its environments. `Retry-After` gives the seconds left in the hour. | Wait for the next hour |
| `500` | `blob_missing` | A retention challenge on an object whose sealed bytes are gone. This is a failed challenge. `retention-challenge` reports it as a FAIL on `retention-answer`, exit code `1`. | Write to Octet with the output |

An object or key of another vault answers `404`, as if it did not exist.

`retention-challenge` prints its other error answers with their own prefix, and exits `4`. Past the hourly limit, a `429 retention_challenge_rate_limited` prints `the server is rate-limiting retention challenges for this vault: retry after <n> s (HTTP 429 retention_challenge_rate_limited)`, and the challenge can run again after that many seconds. Any other error answer, such as a `401` or `403` for the credential, a `404` for an object deleted since it was listed, a `400` or another `5xx`, prints `the vault did not answer the retention challenge:` followed by `<method> <path>: HTTP <status> <code>: <detail>`. None of these says anything about the object.

## Errors before a request

The CLI refuses some commands before it sends anything:

| Message | Cause | What to do |
|---|---|---|
| `no vaults:read token` | No `--token-file`, `OCTET_VAULT_TOKEN_FILE` or `OCTET_VAULT_TOKEN` | Pass the token file |
| The token is empty, not a vault token, or expired | The CLI checks the token before it sends it, and names the file or variable it came from | Mint a new token in the portal |
| `cannot reach <host>: <cause>` | No answer from the host: connection refused, DNS, TLS or a timeout | Check the network and `--base-url` |
| `cannot ask for the passphrase` | No terminal to prompt on | Pass the option or the variable the message names (see [Passphrases](/docs/vaults/reference/cli/#passphrases)) |
| A redirect, with its target | The CLI follows no redirect | Check `--base-url` |

## Exit codes

| Code | Meaning |
|---|---|
| `0` | VALID: no check failed or raised an ALERT |
| `1` | INVALID: a check failed |
| `2` | ALERT: no check failed, and at least one line is an ALERT |
| `3` | INCONCLUSIVE: the result is not established, for example without your app's identity, or for `retention-challenge` on an object whose retention root is not committed yet |
| `4` | Could not run: a credential, the network, a key file, a wrong key or passphrase, a server error, input that cannot be read, or a `monitor` notification that could not be sent |
| `64` | Usage error: a wrong flag or value, a flag and its environment variable that disagree, or a confirmation the CLI could not ask for |

Every error on this page exits `4`, except a usage error, which exits `64`. Two error answers to `retention-challenge` are check lines instead: `500 blob_missing` (FAIL, exit `1`) and `409 retention_root_pending` (ABSENT, INCONCLUSIVE, exit `3`). See [`retention-challenge`](/docs/vaults/reference/checks/#retention-challenge) and [Exit codes](/docs/vaults/reference/cli/#exit-codes).

`subject erase` exits `1` when a legal hold or write-once retention kept some of the subject's objects. See [Erase a subject](/docs/vaults/integration/delete/#erase-a-subject).
