Skip to content

[wrangler] Validate header rules reject multiple wildcards - #12276

Merged
petebacondarwin merged 5 commits into
mainfrom
fix/9739-header-rules-validation
May 2, 2026
Merged

[wrangler] Validate header rules reject multiple wildcards#12276
petebacondarwin merged 5 commits into
mainfrom
fix/9739-header-rules-validation

Conversation

@penalosa

@penalosa penalosa commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #9739.

This PR adds validation in parseHeaders() to reject header rules that:

  • Contain multiple wildcards (e.g., https://*.pages.dev/*)
  • Combine a wildcard with a :splat placeholder (e.g., https://*.pages.dev/:splat)

Previously, such rules were silently accepted during parsing but failed at runtime due to JavaScript regex duplicate named capture group errors. The rule would be quietly filtered out, causing unexpected behavior.

Also, previously when paths were invalid, we would confusingly throw the error message 'Path should come before header', because from the perspective of the parser, the invalid path wasn't there anymore and it was just a bare header.


  • 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: Error messages are self-explanatory and guide users to fix the issue

@changeset-bot

changeset-bot Bot commented Jan 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b844442

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

claude Bot commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

Claude finished @penalosa's task —— View job


Changeset Review

Reviewed changeset file: .changeset/validate-header-rules-wildcards.md

Todo List:

  • Read changeset guidelines
  • Review changeset file
  • Validate against criteria
  • Check for cute animal images
  • Post findings

All changesets look good

The changeset properly:

  • Uses patch version type (appropriate for a bug fix that adds validation)
  • Has a clear, descriptive title following imperative style
  • Provides meaningful explanation of the issue and the fix
  • Contains no h1/h2/h3 headers
  • Does not introduce new analytics
  • Is not a dependabot change
  • Is not an experimental feature

The description clearly explains what was broken (silent runtime failures) and how this fix improves the user experience (early validation with clear error messages).


@penalosa penalosa closed this Jan 29, 2026
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in workers-sdk Jan 29, 2026
@emily-shen emily-shen reopened this Apr 23, 2026
@github-project-automation github-project-automation Bot moved this from Done to Untriaged in workers-sdk Apr 23, 2026
@emily-shen emily-shen self-assigned this Apr 23, 2026
@emily-shen
emily-shen force-pushed the fix/9739-header-rules-validation branch from 0b27920 to 23ad0e2 Compare April 23, 2026 12:11
@github-actions

github-actions Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Changeset Review

File: .changeset/reject-multiple-wildcards-headers.md

Package: @cloudflare/workers-shared
Version Type: patch

Review

Criterion Status Notes
Version Type Patch is appropriate for this bug fix (was failing silently, now warns)
Changelog Quality Clear description of the change and previous behavior
Markdown Headers No h1/h2/h3 headers found
Analytics No analytics changes
Dependabot Not a dependency update
Experimental Features N/A - not an experimental feature change

Summary

The changeset clearly describes:

  • What is being warned about (headers rules with multiple wildcards or wildcard + :splat)
  • Examples of problematic patterns
  • The previous behavior (silent failure during dev)

✅ All changesets look good

@pkg-pr-new

pkg-pr-new Bot commented Apr 23, 2026

Copy link
Copy Markdown
create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: b844442

@emily-shen
emily-shen force-pushed the fix/9739-header-rules-validation branch from 23ad0e2 to 1cdb079 Compare April 23, 2026 14:56
@emily-shen
emily-shen marked this pull request as ready for review April 23, 2026 14:57
@emily-shen
emily-shen requested a review from GregBrimble April 23, 2026 14:59
devin-ai-integration[bot]

This comment was marked as resolved.

@workers-devprod
workers-devprod requested review from a team and emily-shen and removed request for a team April 23, 2026 15:02
@workers-devprod

workers-devprod commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/deploy-config
  • ✅ @cloudflare/wrangler
Show detailed file reviewers
  • packages/workers-shared/utils/configuration/parseHeaders.ts: [@cloudflare/deploy-config]
  • packages/workers-shared/utils/tests/parseHeaders.invalid.test.ts: [@cloudflare/deploy-config]

@emily-shen
emily-shen force-pushed the fix/9739-header-rules-validation branch from 1cdb079 to 95859e1 Compare April 24, 2026 17:41
@petebacondarwin
petebacondarwin force-pushed the fix/9739-header-rules-validation branch from 95859e1 to 5c2585b Compare April 27, 2026 09:15
Comment thread packages/workers-shared/utils/configuration/parseHeaders.ts
Comment thread packages/workers-shared/utils/configuration/parseHeaders.ts
@emily-shen
emily-shen force-pushed the fix/9739-header-rules-validation branch from 5c2585b to 4256c29 Compare April 27, 2026 09:49
devin-ai-integration[bot]

This comment was marked as resolved.

Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@emily-shen
emily-shen removed their request for review April 27, 2026 12:30
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/deploy-config
  • ✅ @cloudflare/wrangler
Show detailed file reviewers
  • packages/workers-shared/utils/configuration/parseHeaders.ts: [@cloudflare/deploy-config]
  • packages/workers-shared/utils/tests/parseHeaders.invalid.test.ts: [@cloudflare/deploy-config]

@petebacondarwin petebacondarwin 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 bypass

@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 May 2, 2026
@petebacondarwin
petebacondarwin merged commit 926bad5 into main May 2, 2026
58 checks passed
@petebacondarwin
petebacondarwin deleted the fix/9739-header-rules-validation branch May 2, 2026 13:25
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk May 2, 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.

Header rules incorrectly accepts invalid rules that silently fail at runtime

4 participants