Skip to content

WC-5233 use patch apis for wrangler preview secret commands - #15043

Open
podonnell-dev wants to merge 5 commits into
cloudflare:mainfrom
podonnell-dev:podonnell/WC-5233-use-patch-apis-preview-secrets
Open

WC-5233 use patch apis for wrangler preview secret commands#15043
podonnell-dev wants to merge 5 commits into
cloudflare:mainfrom
podonnell-dev:podonnell/WC-5233-use-patch-apis-preview-secrets

Conversation

@podonnell-dev

@podonnell-dev podonnell-dev commented Aug 5, 2026

Copy link
Copy Markdown

Fixes WC-5233

Use PATCH APIs for wrangler preview secret commands. Removing the dependence on preview_defaults - all preview secret commands now patch secrets for the latest preview deployment. Also adjusted file conventions to match #14448 more closely

Reviewable, but ask Patrick before merging - we'll be trying to time this release for Tuesday's release


  • 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: refactor

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


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 98ecb45

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

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@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

@workers-devprod
workers-devprod requested review from a team and jamesopstad and removed request for a team August 5, 2026 16:49
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/preview-secret-per-preview.md: [@cloudflare/wrangler]
  • packages/deploy-helpers/src/preview/api.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/tests/preview.secret.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/commands.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/delete.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/preview.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/secret.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/secrets/bulk.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/secrets/delete.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/secrets/index.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/secrets/list.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/secrets/put.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/preview/settings.ts: [@cloudflare/wrangler]

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

View in Devin Review to see 2 additional findings.

Open in Devin Review

Comment thread packages/wrangler/src/preview/secrets/list.ts
Comment thread packages/wrangler/src/__tests__/preview.secret.test.ts
Comment thread packages/wrangler/src/__tests__/preview.secret.test.ts Outdated
Comment thread packages/wrangler/src/__tests__/preview.secret.test.ts Outdated
Comment thread packages/wrangler/src/__tests__/preview.secret.test.ts Outdated
Comment thread packages/wrangler/src/preview/secrets/bulk.ts Outdated
Comment thread packages/wrangler/src/preview/secrets/delete.ts Outdated

@GregBrimble GregBrimble 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.

Only other thing I'd consider testing is: no preview name provided and not in a git worktree.

Comment thread packages/wrangler/src/preview/secrets/index.ts Outdated
@dario-piotrowicz
dario-piotrowicz requested review from dario-piotrowicz and removed request for jamesopstad August 6, 2026 11:05
devin-ai-integration[bot]

This comment was marked as resolved.

@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 found 4 new potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +55 to +59
json: {
describe: "Return output as JSON",
type: "boolean",
default: false,
},

@devin-ai-integration devin-ai-integration Bot Aug 6, 2026

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.

🟡 Output format flag still leaks into the settings update command

The parent settings command's output-format flag is registered as a shared flag (json at packages/wrangler/src/preview/settings.ts:55-59) without opting out of propagation, so it still appears on, and is silently accepted by, the settings update subcommand.
Impact: Users see and can pass an output-format option on a command that ignores it, and the new help test that asserts this option is absent will fail.

Why parent options propagate to subcommands in the yargs tree

Commands are registered nested: wrangler preview settings is a command whose builder also registers wrangler preview settings update (packages/wrangler/src/index.ts:909-916, builder in packages/wrangler/src/core/register-yargs-command.ts:66-129). In yargs, options declared in a parent command's builder default to global: true and are therefore not reset when a subcommand runs, so they remain registered (and displayed in --help) for the subcommand. That is exactly the leak this PR fixes for wrangler preview by adding global: false to every arg in packages/wrangler/src/preview/preview.ts:19-63. The same treatment was not applied to previewSettingsCommand's json arg, yet the new test at packages/wrangler/src/__tests__/preview.test.ts:62-72 forbids --json in preview settings update --help.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Out of scope for current PR added wrangler preview secrets - this is existing behavior

Comment thread packages/wrangler/src/preview/secrets/list.ts
Comment thread packages/wrangler/src/__tests__/preview.test.ts Outdated
Comment thread packages/wrangler/src/preview/secrets/index.ts Outdated
@podonnell-dev
podonnell-dev force-pushed the podonnell/WC-5233-use-patch-apis-preview-secrets branch from 1e113e9 to 7c3c05b Compare August 7, 2026 13:48
@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Aug 7, 2026
@podonnell-dev
podonnell-dev force-pushed the podonnell/WC-5233-use-patch-apis-preview-secrets branch from a3ddfa7 to 98ecb45 Compare August 7, 2026 15:22
@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

npm i https://pkg.pr.new/@cloudflare/build-output-utils@15043

@cloudflare/config

npm i https://pkg.pr.new/@cloudflare/config@15043

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

npm i https://pkg.pr.new/@cloudflare/pages-functions@15043

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 98ecb45

@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 found 1 new potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +60 to +65
if (
args.skipConfirmation ||
(await confirm(
`Are you sure you want to permanently delete the secret ${args.key} on the Preview "${previewName}" for the Worker ${workerName}${args.env ? ` (${args.env})` : ""}?`
))
) {

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.

🟡 Declining the delete confirmation prints nothing

When the user answers "no" to the deletion prompt (confirm(...) at packages/wrangler/src/preview/secrets/delete.ts:62), the command finishes with no output at all, so it looks like the deletion may have succeeded.
Impact: Users who cancel a secret deletion get a silent, ambiguous result instead of a clear cancellation message.

Lost "Aborted." feedback when the confirmation is declined

The previous implementation (packages/wrangler/src/preview/secret.ts before removal) explicitly logged "Aborted." and returned when the user declined the confirmation prompt. The new handler wraps the whole body in if (args.skipConfirmation || await confirm(...)) { ... } with no else branch, so declining produces zero output while still exiting with a success status. Other Wrangler flows (e.g. previewDelete in packages/deploy-helpers/src/preview/preview.ts:800-806) still log "Aborted." in this situation, so this is also an inconsistency with the surrounding conventions.

Prompt for agents
In packages/wrangler/src/preview/secrets/delete.ts, the handler only performs work when the user confirms, but there is no branch for the declined case. The previous implementation logged "Aborted." and returned. Restore user feedback when the confirmation prompt is declined (e.g. early-return with a logged "Aborted." message instead of an if-block with no else), matching previewDelete in packages/deploy-helpers/src/preview/preview.ts.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Mirrors existing wrangler secret delete - ignoring

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.

3 participants