[Pending internal discussions] Exclude trailing comments from _redirects line length validation#12490
Draft
[Pending internal discussions] Exclude trailing comments from _redirects line length validation#12490
_redirects line length validation#12490Conversation
🦋 Changeset detectedLatest commit: b2d4420 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 |
da8987b to
7e8c7fc
Compare
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
petebacondarwin
requested changes
Feb 9, 2026
Contributor
petebacondarwin
left a comment
There was a problem hiding this comment.
The "valid" test needs fixing.
0ded52c to
35096b4
Compare
35096b4 to
09e3bb1
Compare
Contributor
|
Claude encountered an error —— View job Changeset Review
|
_redirects line length validation
GregBrimble
reviewed
Feb 27, 2026
|
|
||
| This is consistent with full line comments where the line length is not limited. | ||
|
|
||
| Additionally, the maximum line length for redirect directives has been corrected to 1000 characters (matching the Workers platform limit), down from 2000. |
Contributor
There was a problem hiding this comment.
Unconvinced by this line. Won't this break people in prod today with 1001 characters?
Contributor
Author
There was a problem hiding this comment.
See the opened questions in the PR description
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow up for #12467
The main idea of this PR is that the maximum line length of a
_redirectsshould not take comments into account.There are also a few other changes.
There was a single
MAX_LINE_LENGTHused for both the_headersand_redirectswhile the first one should be 2000 and second one 1000 (See opened questions below for that one). The new constants areMAX_HEADER_LINE_LENGTHandMAX_REDIRECT_LINE_LENGTH.Note that other constants have been renamed to clearly indicated when they relates to either
HEADERorREDIRECT.Also a bit of cleanup in the tests to make them consistent.
Questions
_redirectsparser version, not sure how it is used - it is defined both here and EWCfuture work
Usage of
_redirects(by Claude and I)1. Workers Assets deploy (
wrangler deploy/wrangler versions upload)packages/wrangler/src/assets.ts:469—maybeGetFile()reads raw textpackages/wrangler/src/deploy/deploy.ts:867(deploy),packages/wrangler/src/versions/upload.ts:726(versions upload)packages/wrangler/src/deployment-bundle/create-worker-upload-form.ts:90—raw string embedded in
AssetConfigMetadataJSON inside the FormDatametadatafieldparseRedirects? No — the Cloudflare API parses it server-side2. Workers Assets remote dev (
wrangler dev --remote)packages/wrangler/src/dev/remote.ts:197parseRedirects? No3. Pages deploy (
wrangler pages deploy)packages/wrangler/src/api/pages/deploy.ts:136—readFileSync()packages/wrangler/src/api/pages/deploy.ts:297-299— appended as aFileobject in FormData (not inside JSON)
parseRedirects? No — the Pages API parses it server-side4. Miniflare local dev (Workers Assets,
wrangler dev --local)packages/miniflare/src/plugins/assets/index.ts:99-124parseRedirects()→constructRedirects()→RedirectsSchema.parse()→ injected asJSON
CONFIGbinding into the local workerd asset-workerparseRedirects? Yes5. Pages local dev (
wrangler pages dev)packages/wrangler/src/miniflare-cli/assets.ts:150-161parseRedirects()→createMetadataObject()→constructRedirects()parseRedirects? Yes6. Vite plugin dev (experimental)
packages/vite-plugin-cloudflare/src/asset-config.ts:105-117parseRedirects()→constructRedirects()→RedirectsSchema.parse()→ passed toMiniflare options
experimental.headersAndRedirectsDevModeSupporthasAssetsConfigChanged()(line 27-46)parseRedirects? Yes7. Runtime: Workers asset-worker
packages/workers-shared/asset-worker/src/handler.ts:48,999-1050packages/workers-shared/asset-worker/src/utils/rules-engine.ts:116-160configuration.redirectsviaCONFIGbindingstaticRedirectsMatcher()(O(1) dict lookup) thengenerateRedirectsMatcher()(regex-based dynamic matching) on each request
8. Runtime: Pages asset-server
packages/pages-shared/asset-server/handler.ts:202-243metadata.redirectspackages/pages-shared/metadata-generator/createMetadataObject.tsA picture of a cute animal (not mandatory, but encouraged)