Skip to content

Slightly improve KV error messages to be clearer and more actionable#14436

Open
dario-piotrowicz wants to merge 2 commits into
mainfrom
dario/kv-error-messages
Open

Slightly improve KV error messages to be clearer and more actionable#14436
dario-piotrowicz wants to merge 2 commits into
mainfrom
dario/kv-error-messages

Conversation

@dario-piotrowicz

@dario-piotrowicz dario-piotrowicz commented Jun 26, 2026

Copy link
Copy Markdown
Member

Error messages for KV namespace and key operations now consistently explain what went wrong, which flags or config fields to use, and what commands to run as alternatives. This covers namespace selection errors (delete, rename), binding resolution errors, config file issues, and preview namespace ambiguity.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: just slightly improving error messages

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f20f39b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Patch
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Jun 26, 2026
@workers-devprod workers-devprod requested review from a team and james-elicx and removed request for a team June 26, 2026 10:59
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/workers-kv
  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/improve-kv-error-messages.md: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/kv/key.test.ts: [@cloudflare/workers-kv @cloudflare/wrangler]
  • packages/wrangler/src/tests/kv/namespace.test.ts: [@cloudflare/workers-kv @cloudflare/wrangler]
  • packages/wrangler/src/kv/helpers.ts: [@cloudflare/workers-kv @cloudflare/wrangler]
  • packages/wrangler/src/kv/index.ts: [@cloudflare/workers-kv @cloudflare/wrangler]

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm Bonk, and I've done a quick review of your PR.

This PR rewords KV namespace/key error messages to be clearer and more actionable, updating the matching test snapshots.

One issue worth a look:

  1. The new message in getIdFromSettings may give misleading guidance for the provisioning path (details inline).

Comment thread packages/wrangler/src/kv/helpers.ts Outdated
if (!existingKV || !("namespace_id" in existingKV)) {
throw new UserError(
`No namespace ID found for binding "${binding}". Add one to your wrangler config file or pass it via \`--namespace-id\`.`,
`No KV namespace ID found for binding "${binding}" in the deployed Worker settings for "${config.name}". Add an "id" to the "${binding}" entry in your config's "kv_namespaces" array, or use \`--namespace-id\` instead.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is only reachable through the RESOURCES_PROVISION flow (called from lines 543 and 566), which by design handles bindings that have no id/preview_id in config and resolves the namespace ID from the deployed Worker's settings instead. In that situation, advising the user to "Add an id to the kv_namespaces array" contradicts the provisioning workflow they're relying on — they intentionally don't have an id yet, and the namespace simply isn't deployed.

Consider keeping the guidance focused on the actual cause (binding not found in the deployed Worker / not yet deployed) and the --namespace-id escape hatch, without pushing them to add an id:

Suggested change
`No KV namespace ID found for binding "${binding}" in the deployed Worker settings for "${config.name}". Add an "id" to the "${binding}" entry in your config's "kv_namespaces" array, or use \`--namespace-id\` instead.`,
`No KV namespace ID found for binding "${binding}" in the deployed Worker settings for "${config.name}". Deploy the Worker so the binding is provisioned, or use \`--namespace-id\` instead.`,

@ask-bonk

ask-bonk Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

I've reviewed PR #14436 and posted a review with one inline suggestion.

Summary: The PR is a clean cosmetic improvement to KV error messages with matching test snapshot updates. The one actionable issue I flagged is that the new message in getIdFromSettings (helpers.ts:428) advises users to add an id to their kv_namespaces config, but that branch is only reachable via the RESOURCES_PROVISION flow where bindings intentionally have no id — making that guidance contradict the provisioning workflow. I posted a suggestion to reword it toward "deploy the Worker" / --namespace-id.

github run

@github-actions

github-actions Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

Reviewed changesets:

  1. .changeset/improve-kv-error-messages.md — patch, clear description
  2. .changeset/explain-workflow-name-conflict.md — patch, clear description
  3. .changeset/improve-versions-deploy-error-messages.md — patch, clear description
  4. .changeset/wrangler-tail-resilient-lifecycle.md — minor, detailed description with bullets explaining new resilience behavior
  5. .changeset/wrangler-queues-subscription-images-source.md — patch, clear description with usage example
  6. .changeset/verify-docker-before-build.md — patch, clear description
  7. .changeset/fix-pipelines-setup-stream-binding.md — patch, clear description

All changesets avoid h1/h2/h3 headers and provide meaningful, user-facing descriptions. No analytics or experimental opt-in concerns identified.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14436

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14436

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14436

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14436

miniflare

npm i https://pkg.pr.new/miniflare@14436

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14436

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14436

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14436

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14436

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14436

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14436

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14436

wrangler

npm i https://pkg.pr.new/wrangler@14436

commit: f20f39b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants