# KV diagnostics

<!-- Generated by docs/modules/diagnostics from the package catalogs. Write a guide in docs/diagnostics/<CODE>.md instead of editing this file. -->

Each KV error has a stable `code`. Its `docs` link opens the page of that code. This page lists all 29 codes, and [All diagnostics](https://vitehub.dev/docs/reference/diagnostics) lists every primitive.

## Runtime errors

| Code | What happened |
| --- | --- |
| [`KV_INVALID_CURSOR`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_cursor) | See the page of the code. |
| [`KV_INVALID_LIMIT`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_limit) | `limit` must be a positive integer. |
| [`KV_INVALID_OPTION`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_option) | kv.\<operation\>() does not accept the option `<option>`. It accepts only `ttl`. |
| [`KV_INVALID_TTL`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_ttl) | `ttl` must be a positive number of seconds within the safe integer range. |
| [`KV_INVALID_VALUE`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_value) | kv.\<operation\>() needs a value. Use kv.delete() to remove a key. |
| [`KV_INVALID_WAIT`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_wait) | `wait` must be zero or a positive number of seconds. |
| [`KV_KEY_TOO_LONG`](https://vitehub.dev/docs/kv/diagnostics/kv_key_too_long) | The key is \<bytes\> bytes in UTF-8. Cloudflare KV accepts keys of at most \<limit\> bytes. |
| [`KV_OPERATION_FAILED`](https://vitehub.dev/docs/kv/diagnostics/kv_operation_failed) | kv.\<operation\>() failed on the "\<store\>" store. |
| [`KV_UNSUPPORTED_OPERATION`](https://vitehub.dev/docs/kv/diagnostics/kv_unsupported_operation) | kv.\<operation\>() needs atomic operations, and the "\<store\>" store does not support them. |
| [`KV_VALUE_TOO_LARGE`](https://vitehub.dev/docs/kv/diagnostics/kv_value_too_large) | The value is \<bytes\> bytes. Cloudflare KV accepts values of at most \<limit\> bytes (25 MiB). |

## Configuration errors

| Code | What happened |
| --- | --- |
| [`KV_DATABASE_UNAVAILABLE`](https://vitehub.dev/docs/kv/diagnostics/kv_database_unavailable) | The KV `database` driver keeps keys in the Database "\<database\>", and the app has no Database with that name. |
| [`KV_DENO_KV_UNAVAILABLE`](https://vitehub.dev/docs/kv/diagnostics/kv_deno_kv_unavailable) | The `deno-kv` driver needs `Deno.openKv()`, and this runtime does not have it. |
| [`KV_DISABLED`](https://vitehub.dev/docs/kv/diagnostics/kv_disabled) (guide) | KV is not configured in this runtime. |
| [`KV_INVALID_BATCH`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_batch) | `kv.setMany()` needs an array of `{ key, value }` entries. |
| [`KV_INVALID_CONFIG`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_config) | `<path>` must be a plain object. |
| [`KV_INVALID_DRIVER`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_driver) | `kv.driver` is \<driver\>. ViteHub renamed this driver to "\<renamed\>", and it does not read \<driver\>. |
| [`KV_INVALID_REMOTE`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_remote) | `remote` of the KV store "\<store\>" must be `true` or `false`. |
| [`KV_INVALID_STORE_MODE`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_store_mode) | `kv.store()` mode \<mode\> is not "read" or "write". |
| [`KV_MISSING_DEFAULT_STORE`](https://vitehub.dev/docs/kv/diagnostics/kv_missing_default_store) | `kv.stores.default` is missing. |
| [`KV_MISSING_ENV`](https://vitehub.dev/docs/kv/diagnostics/kv_missing_env) | \<value\> KV needs the runtime environment variable \<names\>. |
| [`KV_REMOTE_CONFLICT`](https://vitehub.dev/docs/kv/diagnostics/kv_remote_conflict) | The KV store "\<store\>" sets `remote: true`, but it uses the local `<driver>` driver in `vite dev`. |
| [`KV_STORE_NOT_FOUND`](https://vitehub.dev/docs/kv/diagnostics/kv_store_not_found) (guide) | KV store "\<store\>" was not found. Stores: \<stores\>. |

## Provider and tool errors

| Code | What happened |
| --- | --- |
| [`KV_CLI_USAGE`](https://vitehub.dev/docs/kv/diagnostics/kv_cli_usage) | See the page of the code. |
| [`KV_INVALID_COUNTER`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_counter) | kv.increment() needs a stored integer below 9007199254740991. The value did not change. |
| [`KV_PROVIDER_INVALID_RESPONSE`](https://vitehub.dev/docs/kv/diagnostics/kv_provider_invalid_response) | The KV provider returned a response that ViteHub cannot use. \<problem\> |
| [`KV_PROVISION_FAILED`](https://vitehub.dev/docs/kv/diagnostics/kv_provision_failed) | Cloudflare KV provisioning failed. \<problem\> |

## Operation errors

| Code | What happened |
| --- | --- |
| [`KV_INVALID_INPUT`](https://vitehub.dev/docs/kv/diagnostics/kv_invalid_input) | The \<operation\> operation requires a key. |
| [`KV_RESERVED_KEY`](https://vitehub.dev/docs/kv/diagnostics/kv_reserved_key) | The \<operation\> operation cannot change \<key\>. ViteHub owns the keys that start with `vitehub:`. |
| [`KV_VALUE_UNSUPPORTED`](https://vitehub.dev/docs/kv/diagnostics/kv_value_unsupported) | The stored value cannot be represented by the KV inspection protocol. |

<!-- vitehub-docs:section-links -->
## In this section

- [Overview](https://vitehub.dev/raw/docs/kv.md)
- [Get started](https://vitehub.dev/raw/docs/kv/get-started.md)
- [Configure](https://vitehub.dev/raw/docs/kv/configure.md)
- [Server API](https://vitehub.dev/raw/docs/kv/server-api.md)
- [Agent capability](https://vitehub.dev/raw/docs/kv/agent-capability.md)
- [Hosts](https://vitehub.dev/raw/docs/kv/hosts.md)
- [Limits and errors](https://vitehub.dev/raw/docs/kv/limits-and-errors.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
