You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cloudflare): accept trailing commas in the wrangler config - #5142
📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
🐞 Bug fix (a non-breaking change that fixes an issue)
👌 Enhancement (improving an existing functionality like performance)
✨ New feature (a non-breaking change that adds functionality)
🧹 Chore (updates to the build process or auxiliary tools and libraries)
⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
A trailing comma in the project's wrangler.jsonc or wrangler.json fails nitro build with SyntaxError: Expected double-quoted property name in JSON. Since confbox 0.3, parseJSONC only accepts trailing commas with allowTrailingComma: true. Wrangler accepts them in both files.
This PR passes allowTrailingComma: true when Nitro reads the Wrangler config. The new test in test/unit/cloudflare.utils.test.ts fails on main and passes here.
No actionable comments were generated in the recent review.
Walkthrough
JSON and JSONC Wrangler configurations now allow trailing commas during parsing. A test verifies that writeWranglerConfig reads a commented wrangler.jsonc file with a trailing comma and includes its parsed values in the generated configuration.
Changes: Cloudflare configuration parsing
Layer / File(s)
Summary
Allow trailing commas in Wrangler configuration src/presets/cloudflare/utils.ts, test/unit/cloudflare.utils.test.ts
JSON and JSONC parsing now explicitly allows trailing commas. A test checks that writeWranglerConfig preserves the name and vars values from a commented wrangler.jsonc file.
Nitro's Cloudflare build now accepts trailing commas in wrangler.json and wrangler.jsonc, matching Wrangler's behavior. Previously valid configs parse the same way, so the risk of merging is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title uses the conventional commits format (fix(cloudflare): ...) and describes the change: the Cloudflare preset now accepts trailing commas in the Wrangler config. This matches the main change, …
Description check
The description states the bug (a trailing comma in wrangler.jsonc or wrangler.json fails nitro build), the cause (confbox parseJSONC needs allowTrailingComma: true), the fix (passing that option when…
Linked Issues check
Issue #5141 requires Nitro's Cloudflare config reader to accept trailing commas in project wrangler.jsonc and wrangler.json files. At head, src/presets/cloudflare/utils.ts defines parseWranglerJSON as…
Out of Scope Changes check
The whole-PR diff against the merge base 749b12b changes only src/presets/cloudflare/utils.ts and test/unit/cloudflare.utils.test.ts. The source change swaps the JSON and JSONC parsers for a trailing-…
Full details: Title check
Explanation
The title uses the conventional commits format (fix(cloudflare): ...) and describes the change: the Cloudflare preset now accepts trailing commas in the Wrangler config. This matches the main change, which passes allowTrailingComma: true when Nitro reads wrangler.json and wrangler.jsonc.
Full details: Description check
Explanation
The description states the bug (a trailing comma in wrangler.jsonc or wrangler.json fails nitro build), the cause (confbox parseJSONC needs allowTrailingComma: true), the fix (passing that option when Nitro reads the Wrangler config), and the new test. This matches the changeset.
Full details: Linked Issues check
Explanation
Issue #5141 requires Nitro's Cloudflare config reader to accept trailing commas in project wrangler.jsonc and wrangler.json files. At head, src/presets/cloudflare/utils.ts defines parseWranglerJSON as parseJSONC(text, { allowTrailingComma: true }) and maps both the ".json" and ".jsonc" extensions to it. The TOML parser is unchanged. The new test in test/unit/cloudflare.utils.test.ts writes a wrangler.jsonc with a comment and trailing commas, runs writeWranglerConfig, and asserts that name and vars are parsed. The diff does not add a test for a wrangler.json file, but the code path for both extensions is the same. The issue does not require a specific test. The coding requirement is met.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base 749b12b changes only src/presets/cloudflare/utils.ts and test/unit/cloudflare.utils.test.ts. The source change swaps the JSON and JSONC parsers for a trailing-comma-tolerant parser. The test change adds one case for that behavior. Both changes connect directly to issue #5141. No unrelated changes were found in the diff.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: fb1a90df-5a3b-407d-8662-24c7d14c27f3
Commits
Reviewing files that changed from the base of the PR and between 749b12b and ad8c572.
Files selected for processing: 2
src/presets/cloudflare/utils.ts
test/unit/cloudflare.utils.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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
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.
🔗 Linked issue
resolves #5141
❓ Type of change
📚 Description
A trailing comma in the project's
wrangler.jsoncorwrangler.jsonfailsnitro buildwithSyntaxError: Expected double-quoted property name in JSON. Since confbox 0.3,parseJSONConly accepts trailing commas withallowTrailingComma: true. Wrangler accepts them in both files.This PR passes
allowTrailingComma: truewhen Nitro reads the Wrangler config. The new test intest/unit/cloudflare.utils.test.tsfails onmainand passes here.📝 Checklist