Skip to content

[wrangler] fix: improve R2 CORS validation and error messaging#12456

Open
venkatnikhilm wants to merge 4 commits intocloudflare:mainfrom
venkatnikhilm:fix/r2-cors-validation
Open

[wrangler] fix: improve R2 CORS validation and error messaging#12456
venkatnikhilm wants to merge 4 commits intocloudflare:mainfrom
venkatnikhilm:fix/r2-cors-validation

Conversation

@venkatnikhilm
Copy link

@venkatnikhilm venkatnikhilm commented Feb 6, 2026

This PR addresses #8486 by adding local validation to the r2 bucket cors set command.

Previously, users providing AWS S3-formatted CORS files (using CORSRules or PascalCase keys like AllowedOrigins) would receive a generic 10040 API error from the server. This PR intercepts these common formatting mistakes locally, providing a descriptive error message and a link to the correct Cloudflare R2 documentation.

Validation conducted:

  • Manual Test (AWS Format): Verified that a file containing CORSRules or AllowedOrigins triggers the new custom error message.
  • Manual Test (R2 Format): Verified that a correctly formatted R2 CORS file passes validation and proceeds to the API call.
  • Linting/Types: Successfully ran pnpm run check --filter wrangler in the project root with 0 errors.

Changes:

  • Modified packages/wrangler/src/r2/cors.ts to include a validation layer using parseJSON.
  • Added detection for AWS-specific top-level keys and PascalCase property keys.
  • Included an official documentation link in the error output.

Open with Devin

@venkatnikhilm venkatnikhilm requested a review from a team as a code owner February 6, 2026 23:14
@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2026

🦋 Changeset detected

Latest commit: ccdf0cc

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

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 3 additional findings in Devin Review.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments