[BUG] Edit tool settings. json validator fails with "Unterminated string" when old string spans a line with backslash sequences
Resolved 💬 1 comment Opened May 6, 2026 by aristretto Closed Jun 4, 2026
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
When using the Edit tool to modify ~/.claude/settings.json, the post-edit validator throws Invalid JSON: JSON Parse error: Unterminated string if old_string spans a line containing a permission rule with backslash sequences. The file on disk is valid JSON - the validator accepted it when originally written. The error fires before any write occurs, so the file is never actually corrupted.
What Should Happen?
Expected behavior
Edit succeeds; Bash(jq *) is added to the allow list.
Error Messages/Logs
Invalid JSON: JSON Parse error: Unterminated string
Steps to Reproduce
- Add
"Bash(grep -E '\\.md$')"topermissions.allowin~/claude/settings.json:
{
"permissions": {
"allow": [
"Bash(grep -E '\\.md$')",
"Bash(git *)"
]
}
}
- Use the
Edittool with anold_stringthat includes that line:
old_string: "Bash(grep -E '\\.md$')",\n "Bash(git *)"
new_string: "Bash(grep -E '\\.md$')",\n "Bash(git *)",\n "Bash(jq *)"
- Observe:
Invalid JSON: JSON Parse error: Unterminated string
Workaround
Target a line that doesn't contain backslashes in old_string:
old_string: "Bash(git *)"
new_string: "Bash(git *)",\n "Bash(jq *)"
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.128
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Warp
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗