Skip to content

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Feb 7, 2026

Fixes #4193.

Allow deleting a KV namespace by providing its name as a positional argument:

wrangler kv namespace delete my-namespace

This aligns the delete command with the create and rename commands, which also accept namespace names. The existing --namespace-id and --binding flags continue to work as before.

Implementation

The namespace name lookup logic has been centralized in the getKVNamespaceId() helper, which now:

  • Accepts an optional namespace parameter for lookup by name
  • Returns { namespaceId, displayName } instead of just a string
  • Formats displayName to show both the identifier and ID (e.g., my-binding (abc123))

This improves UX across all KV commands by showing more context in log messages.


  • 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: The CLI help text is updated automatically and the usage is intuitive

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

🐱

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: 355ab44

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

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

@claude
Copy link
Contributor

claude bot commented Feb 7, 2026

Claude finished @petebacondarwin's task —— View job


Changeset Review

  • Read changeset guidelines
  • Read changeset file
  • Validate changeset
  • Post review feedback

All changesets look good

The changeset .changeset/kv-namespace-delete-by-name.md follows all guidelines:

  1. Version Type: Minor is correct - this adds new functionality (positional argument support)
  2. Changelog Quality: Clear description with usage example showing the new behavior
  3. Markdown Headers: No h1/h2/h3 headers used
  4. Format: Proper title + body structure with code example
  5. Context: Explains alignment with existing create command and backward compatibility

The changeset effectively communicates the new feature to users and includes a practical example.


Cuteness Report: This is Cat. Appeared as an emoji in the PR description. Would rate but needs higher resolution for proper assessment. Still appreciated. 🐱/10

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 7, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 355ab44

@petebacondarwin petebacondarwin force-pushed the fix/4193-kv-namespace-behavior branch from fb14dfa to e86dbef Compare February 7, 2026 15:48
@petebacondarwin
Copy link
Contributor Author

I have tested this manually using the PR preview to prove that the backend APIs being hit work as expected.

@petebacondarwin petebacondarwin marked this pull request as ready for review February 7, 2026 18:10
@petebacondarwin petebacondarwin requested review from a team as code owners February 7, 2026 18:10
Copy link
Contributor

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

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 potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Feb 7, 2026
@petebacondarwin petebacondarwin force-pushed the fix/4193-kv-namespace-behavior branch from e86dbef to a4f6dc5 Compare February 8, 2026 14:11
vicb
vicb previously requested changes Feb 8, 2026
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

See inline comments.

Could you please also fix the description ?

When deleting by name, the command will:

List all namespaces for the account
Find the namespace with the matching title
Delete the namespace by its ID
Display both the name and ID in the confirmation message
  • explain why list, i.e. because no find by name
  • title -> name
  • "Display both the name and ID in the confirmation message" doesn't look like this is what is implemented

@github-project-automation github-project-automation bot moved this from Approved to In Review in workers-sdk Feb 8, 2026
@petebacondarwin petebacondarwin requested a review from vicb February 8, 2026 17:10
@petebacondarwin petebacondarwin added the blocked Blocked on other work label Feb 9, 2026
@petebacondarwin
Copy link
Contributor Author

Don't land this until the KV team have reviewed and we have resolved the questions around the title vs name naming.

@vicb vicb dismissed their stale review February 9, 2026 14:43

name vs title is being discussed with the KV team

@petebacondarwin petebacondarwin removed the blocked Blocked on other work label Feb 9, 2026
@petebacondarwin
Copy link
Contributor Author

All "title" references have been removed, except for tests that continue to respond with the same format as the API.
@vicb - PTAL.

@petebacondarwin petebacondarwin force-pushed the fix/4193-kv-namespace-behavior branch from 5355b7a to a45b2ce Compare February 10, 2026 16:15
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

LGTM with a few question.
Thanks for the updates

@petebacondarwin petebacondarwin force-pushed the fix/4193-kv-namespace-behavior branch from a45b2ce to 9abf561 Compare February 10, 2026 19:22
Copy link
Contributor

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

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 12 additional findings in Devin Review.

Open in Devin Review

@petebacondarwin petebacondarwin force-pushed the fix/4193-kv-namespace-behavior branch from 9abf561 to 364599b Compare February 11, 2026 09:31
Add ability to delete a KV namespace by providing its name as a
positional argument (e.g., `wrangler kv namespace delete my-namespace`).

This aligns the delete command with the create and rename commands,
which also accept namespace names. The existing --namespace-id and
--binding flags continue to work as before.

Fixes #4193
- Add namespace name lookup support to getKVNamespaceId() helper
- Return { namespaceId, displayName } instead of just string for better UX
- Update all KV command callers to use the new return type
- Use displayName in log messages for friendlier output (e.g. 'my-binding (abc123)')
- Update test snapshots to reflect the new output format
@petebacondarwin petebacondarwin force-pushed the fix/4193-kv-namespace-behavior branch from ae49aa4 to 355ab44 Compare February 11, 2026 11:54
@petebacondarwin petebacondarwin merged commit 10a1c4a into main Feb 11, 2026
39 of 40 checks passed
@petebacondarwin petebacondarwin deleted the fix/4193-kv-namespace-behavior branch February 11, 2026 15:40
@github-project-automation github-project-automation bot moved this from In Review to Done in workers-sdk Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

🚀 Feature Request: Align KV:namespace create/delete behavior

3 participants