Repository navigation
[wrangler] Fall back to per-zone routes when a 403 omits code 10000 - #15798
RealBhupesh wants to merge 3 commits into
Conversation
Bulk route updates only retried per zone for error code 10000. The same missing All Zones rejection can arrive as HTTP 403 with a null code, which aborted deploy after the script upload. Fixes cloudflare#15718
🦋 Changeset detectedLatest commit: cfde482 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
The zone fallback used to run for error code 10000 at any HTTP status. Requiring 403 dropped the existing Wrangler route tests, which return that code with status 200. A missing code still falls back only on 403.
The zone fallback used to run for error code 10000 at any HTTP status. Requiring 403 dropped the existing Wrangler route tests, which return that code with status 200. A missing code still falls back only on 403.
| return false; | ||
| } | ||
|
|
||
| return e.code === 10000 || (e.status === 403 && e.code == null); |
There was a problem hiding this comment.
🔴 Server failures leave old routes attached
When the bulk update returns HTTP 500 with code 10000, isRoutesPermissionError selects the per-zone fallback. That fallback cannot delete existing routes, so deploy can succeed while routes slated for removal remain attached.
Learn more
The bulk route request replaces the Worker's route list. The per-zone fallback only adds routes and warns about existing ones; it cannot remove routes (publishRoutesFallback). The API can return HTTP 500 with error code 10000 for an internal server error, as the server-error fixture demonstrates. Treating that response as a permission error can hide the failed bulk replacement and leave unwanted routes in place.
Example: A Worker has old.example.com/*, and the next deploy requests only new.example.com/*. If the bulk request fails with HTTP 500 and code 10000, fallback adds the new route but leaves the old route attached; deploy reports success.
Recommended fix: Distinguish server failures from the permission rejection before calling publishRoutesFallback; preserve support for genuine non-403 authentication responses such as HTTP 200 with code 10000.
Was this helpful? React with 👍 or 👎 to provide feedback.
|
Sorry, but I don't think this is the right fix for the observed problem. A 403 error should not imply "try again with per-zone routes", and even the current workaround is flawed because it doesn't remove routes that should be removed by the batch update. I'll work with the upstream team to ideally aim for even the code: 10000 to not be necessary. |
Fixes #15718.
wrangler deployuploads the script, then updates routes with one bulk request. That request is supposed to fall back to the zone API when the token lacks All Zones. The fallback only ran for error code 10000. The same 403 is sometimes returned withcode: null, so the deploy aborted even though the script was already uploaded.A 403 with code 10000 or with no code now uses the existing per-zone fallback. A 403 that carries a different code still fails.
Made with Cursor