Skip to content

[wrangler] Don't report rollback success after declining changed secrets confirmation - #16284

Merged
dario-piotrowicz merged 1 commit into
cloudflare:mainfrom
karloper:wrangler-rollback-cancel-output
Oct 15, 2026
Merged

dario-piotrowicz merged 1 commit into
cloudflare:mainfrom
karloper:wrangler-rollback-cancel-output

Conversation

@karloper

Copy link
Copy Markdown
Contributor

Fixes the "Cancelled rollbacks are reported as successful" pain point from the internal Versioned Secrets pain points doc (no GH issue). Supersedes #16269.

When wrangler rollback hits the changed-secrets check (API error 10220) and the user declines the confirmation, Wrangler printed Aborting rollback... and then fell through to the success path:

✔ The following secrets have changed since version de6161e9-… was deployed. Please confirm you wish to continue with the rollback
  * API_KEY … no
╰  X  Aborting rollback...
╰  SUCCESS  Worker Version de6161e9-… has been deployed to 100% of traffic.

Current Version ID: de6161e9-…

No deployment is made and the original version stays live (wrangler deployments status confirms this), but the output and the Current Version ID line say otherwise. Scripts, pipelines and agents that read the output get the same wrong answer.

Changes

  • versions/rollback/index.ts: return after cli.cancel("Aborting rollback...") in the changed-secrets branch, matching how declining the first "Are you sure…" prompt already behaves.
  • rollback.test.ts:
    • New test: declining the changed-secrets confirmation makes exactly one, non-forced deployment request, prints Aborting rollback..., and prints no success message or Current Version ID. Fails without the fix.
    • The existing changed-secrets tests never reached the secrets prompt. They didn't run as a TTY, so confirm() used the non-interactive fallback (yes) instead of the mocks. And msw ignores query strings when matching, so the ?force=true handler answered the first request and the 10220 path never ran.
    • Replaced the two handlers with one, mockPostDeploymentWithChangedSecrets. It rejects non-forced requests with 10220, accepts ?force=true, and records the force value of each request, so the tests assert the exact request sequence ([null, "true"] for confirm or non-interactive, [null] for decline) without depending on handler registration order.
    • Added afterEach(clearDialogs), as other test files do, so unused prompt mocks fail the test. On main, all three existing tests fail this check.

Verification

  • pnpm run test:ci src/__tests__/rollback.test.ts: the new test fails before the fix, and all 4 tests pass after it.
  • oxfmt, oxlint (--type-aware) and tsc are clean on the changed files.
  • Manual, against a real Worker: deploy API_KEY=key-v1, rotate to key-v2, run wrangler rollback <v1> with this branch, and decline the secrets prompt. Output ends at Aborting rollback..., and wrangler deployments status still shows the rotated version at 100%.
  • For comparison, the cf CLI (cf workers deployments create without --force) returns the 10220 APIError and exits 1, so it doesn't have this problem.

Not changed

A cancelled rollback still exits with code 0, the same as declining the first prompt. Exiting non-zero on cancel would let automation tell a cancel apart from a success, but it changes behaviour, so I've left it out of this PR.


  • 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: bug fix to CLI output, no documented behaviour changes

Note

This is a contribution from an AI agent: Devin, Claude Opus 5.5, under human supervision.

…ets confirmation

Declining the changed secrets confirmation in `wrangler rollback` printed
"Aborting rollback..." and then fell through to the success path, so the
output claimed the target version was live and printed it as the
"Current Version ID" while the original version was still serving traffic.

Return after cancelling, matching how declining the initial confirmation
already behaves.

The existing changed secrets tests never reached the secrets prompt: they
didn't run as a TTY, and the `?force=true` handler answered the first
request because msw ignores query strings. Tests now run interactively,
assert on the `force` query parameter of each deployment request, and fail
on unused dialog mocks.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e721f97

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

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-plugin 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-actions

Copy link
Copy Markdown
Contributor

Hi @karloper. Thanks for taking the time to contribute to Workers SDK.

This PR has been automatically closed because you are not currently a registered (vouched) collaborator for this repository.

AI tools now let our team generate proposed code changes quickly. Reviewing changes, checking that they solve the right problem, and maintaining code quality over time still take substantial care and effort. We therefore limit PRs to registered collaborators so we can focus that effort where it is most useful.

For the majority of external contributors, the most effective way to help is through issues: describing a problem or use case, providing a minimal reproduction, investigating its cause, or helping us verify a fix. Those contributions help us understand what needs to change and are very welcome.

We will take an initial look at this PR and decide whether it is something we want to invest time in reviewing and maintaining. We may reopen it if we decide to proceed, but we cannot guarantee that it will be reopened or receive a full review.

@github-actions github-actions Bot closed this Oct 15, 2026
@yomna-shousha yomna-shousha reopened this Oct 15, 2026
@github-project-automation github-project-automation Bot moved this from Done to Untriaged in workers-sdk Oct 15, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

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

@cloudflare/build-output-utils

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

@cloudflare/codemods

npm i https://pkg.pr.new/@cloudflare/codemods@16284

@cloudflare/config

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

@cloudflare/containers-shared

npm i https://pkg.pr.new/@cloudflare/containers-shared@16284

create-cloudflare

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

@cloudflare/deploy-helpers

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-functions

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

@cloudflare/pages-shared

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

@cloudflare/runtime-types

npm i https://pkg.pr.new/@cloudflare/runtime-types@16284

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-plugin

npm i https://pkg.pr.new/@cloudflare/vitest-plugin@16284

@cloudflare/workers-auth

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: e721f97

@yomna-shousha
yomna-shousha marked this pull request as ready for review October 15, 2026 14:10
@workers-devprod
workers-devprod requested review from a team and NuroDev and removed request for a team October 15, 2026 14:10
@workers-devprod

workers-devprod commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

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

Devin Review

@dario-piotrowicz
dario-piotrowicz requested review from dario-piotrowicz and removed request for NuroDev October 15, 2026 14:25

@dario-piotrowicz dario-piotrowicz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, thanks for the fix @karloper ! 😄

@workers-devprod workers-devprod 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.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Oct 15, 2026
@dario-piotrowicz
dario-piotrowicz merged commit 42c6912 into cloudflare:main Oct 15, 2026
217 of 233 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Oct 15, 2026
brandhaug added a commit to brandhaug/b2b-saas-starter that referenced this pull request Oct 19, 2026
## pnpm-workspace.yaml (default)

## Dependency Updates

| Package | From | To | Type |
| --- | --- | --- | --- |
| `wrangler` | 4.151.0 | 4.151.1 | patch |

## Release Notes

<details>
<summary><b>wrangler</b> (4.151.0 → 4.151.1)</summary>

### Patch Changes

- [#15541](cloudflare/workers-sdk#15541)
[`e13d5cc`](cloudflare/workers-sdk@e13d5cc)
Thanks [@<!---->mack-erel](https://github.com/mack-erel)! - Keep remote
dev sessions alive through transient network failures

`wrangler dev --remote` and `getPlatformProxy()` refresh their preview
token before it expires, but a single failed refresh — for example while
the network was briefly down — stopped refreshing for good, leaving the
session broken until restart. A failed refresh now retries every minute
until it succeeds. Rebuilds also no longer push the refresh past the
session's expiry.

- [#16284](cloudflare/workers-sdk#16284)
[`42c6912`](cloudflare/workers-sdk@42c6912)
Thanks [@<!---->karloper](https://github.com/karloper)! - Fix `wrangler
rollback` reporting success after the changed secrets confirmation is
declined

Previously, declining the "The following secrets have changed…"
confirmation printed "Aborting rollback..." and then also printed a
success message and the target version as the "Current Version ID", even
though no deployment was made and the original version was still live.
Wrangler now stops after aborting, so the output matches what is
actually deployed.

- [#13742](cloudflare/workers-sdk#13742)
[`4a5377f`](cloudflare/workers-sdk@4a5377f)
Thanks [@<!---->edmundhung](https://github.com/edmundhung)! - Hide the
`wrangler dev` hotkey bar when Turborepo does not forward input

- Updated dependencies
[[`e1d1b77`](cloudflare/workers-sdk@e1d1b77)]:
  - [email protected]

</details>

---
*This PR was auto-generated by
[catalog-update-action](https://github.com/brandhaug/catalog-update-action).*

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

4 participants