agent's wrangler.jsonc edit broke comment parsing: deploy read a stale config
Fixes deploys reading stale config after the agent's wrangler.jsonc edit broke comment parsing. Use when config edits do not take effect or wrangler falls back to defaults. Not for wrangler.toml syntax errors or intended config values being wrong.
TL;DR
The agent edited wrangler.jsonc and broke the comment syntax (or the JSON structure around a comment), so wrangler could not parse the file and fell back to defaults or a stale cached config. The deploy then used the wrong settings. Validate the JSONC after every edit and diff the effective config before deploying.
The query
agent's wrangler.jsonc edit broke comment parsing: deploy read a stale configUse this when
- Config edits do not take effect on deploy.
- Wrangler warns about config parsing or silently uses defaults.
- The file was recently edited by an agent.
Not for
- wrangler.toml syntax errors (different file, different parser).
- Config values that are valid but wrong (fix the values).
- Deploys failing on validation of correct config (different problem).
Steps
Step 1: Validate the JSONC
Parse the file with a JSONC-aware parser and find the syntax error.
Expected result: the broken comment or structure is located: an unclosed block comment, a comment inside a string, a trailing comma the parser rejects.
Step 2: Fix the syntax minimally
Repair the comment or structure with the smallest possible edit.
Expected result: the file parses cleanly. The intended config change is preserved.
Step 3: Diff the effective config
Compare what wrangler resolves (via dry run) against what you intended.
Expected result: the resolved config matches intent. No silent fallbacks to defaults.
Step 4: Check for the stale-config mechanism
Determine whether wrangler used defaults, a cached config, or the pre-edit file. Understanding the fallback prevents misdiagnosis next time.
Expected result: the fallback behavior is known and documented for the team.
Step 5: Add config validation to the agent's edit flow
Every jsonc edit ends with a parse check and a dry-run diff before deploy.
Expected result: broken configs never reach deploy. The edit-verify loop is structural, not voluntary.
Why it happens
JSONC looks like JSON but is not; comments are the trap. Agents edit confidently (it is 'just JSON'), break a comment boundary, and the parser rejects the file. Wrangler's fallback (defaults or stale) then makes the failure silent: the deploy 'works' with the wrong config.
Edge cases
- Block comments spanning the edited region are the most fragile. Prefer line comments near edit sites.
- A comment containing JSON-like text can confuse naive parsers. Keep comments plain.
- Version-control the config and diff every agent edit. The diff is the cheapest validator.
- Consider whether the project even needs jsonc: if no comments are used, plain JSON removes the entire failure class.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_HuBMBDwcZNbdneMpw3f5Yg