#8486 Wrangler fails to validate R2 cors file properly and should error more helpfully
Maintainer-acknowledged bug. PR #10111 open since July 2025 to fix AWS S3 format detection and improve error messages. Not merged yet.
Follow up on PR #10111 to get it reviewed and merged
Analysis Report
Issue #8486 Review Report
Summary
| Field | Value |
|---|---|
| Title | Wrangler fails to validate R2 cors file properly and should error more helpfully |
| State | OPEN |
| Created | 2025-03-14 |
| Updated | 2025-10-30 |
| Labels | bug, quick win, r2, error-messaging |
Problem Description
User attempts to set R2 bucket CORS policy using wrangler r2 bucket cors set but receives an unhelpful error message: "The JSON you provided was not well formed. [code: 10040]"
The root cause is a mismatch between the expected JSON format (Cloudflare R2 format) and AWS S3-style CORS format that users commonly attempt to use. The error message doesn't help users understand what's wrong or how to fix it.
User's format (AWS S3-style - incorrect):
{
"rules": [
{
"AllowedOrigins": ["http://example.com"],
"AllowedMethods": ["GET", "HEAD", "PUT", "POST", "DELETE"],
"AllowedHeaders": ["Authorization", "Content-Type"],
"ExposeHeaders": ["ETag"],
"MaxAgeSeconds": 3600
}
]
}
Correct Cloudflare R2 format:
{
"rules": [
{
"allowed": {
"origins": ["http://example.com"],
"methods": ["GET", "HEAD", "PUT", "POST", "DELETE"],
"headers": ["Authorization", "Content-Type"]
},
"exposeHeaders": ["ETag"],
"maxAgeSeconds": 3600
}
]
}
Analysis
Maintainer Acknowledgment
A Cloudflare team member (dario-piotrowicz) acknowledged the issue on 2025-04-07, confirming there is something wrong and that they will look into it.
Related PR Found
PR #10111 - "feat: improve CORS validation with AWS S3 format detection"
- State: OPEN (not merged)
- Created: 2025-07-29
- Purpose: Directly addresses issue #8486 by:
- Adding AWS S3 format detection with helpful conversion examples
- Using Zod-based validation for robust error handling
- Providing specific, actionable error messages
- Maintaining backward compatibility
Version Check
- Issue reported version: wrangler 4.0.0, 3.114.1
- Current wrangler version: 4.60.0
- Changelog check: No mention of #8486 fix in changelog
Comments Analysis
- Additional user confirmed issue on wrangler 4.2.0 (2025-03-19)
- Community member provided workaround with correct format (2025-03-31)
- Maintainer acknowledged issue (2025-04-07)
- User noted documentation issue (2025-07-24)
Recommendation
KEEP OPEN - The issue is valid and actively being worked on.
Reasoning:
- The issue represents a real usability problem with unhelpful error messages
- A maintainer has acknowledged the problem
- PR #10111 is open and directly addresses this issue
- The fix has not been merged yet
- Multiple users have confirmed the issue across different wrangler versions
- The issue is labeled as "quick win" indicating it's been triaged
Suggested Actions:
- Follow up on PR #10111 to get it reviewed and merged
- Consider updating documentation at https://developers.cloudflare.com/r2/buckets/cors/#example as noted in comments
- Once PR is merged, this issue can be closed
Reproduction Status
Not attempted - issue is clearly valid with maintainer acknowledgment and an open fix PR.
Notes & Feedback (0)
No notes yet.