refactor(ignore): guard ignore-side Claude settings JSON.parse with try/catch - #2126
Merged
Merged
Conversation
…ry/catch The Claude Code ignore feature parsed an existing `.claude/settings.json` with a bare `JSON.parse`, so a corrupted settings file surfaced an unformatted error. The permissions side (`claudecode-permissions.ts`) already wraps this in a try/catch that rethrows a `Failed to parse existing Claude settings at <path>` message. Mirror that here for consistency, and add a test covering the malformed input path. Closes #2121 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
@dyoshikawa Thank you! |
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Background
Follow-up from the review of PR #2115 (captured in #2121). Finding 3: the Claude Code ignore feature parsed an existing
.claude/settings.jsonwith a bareJSON.parse(src/features/ignore/claudecode-ignore.ts), so a corrupted settings file surfaced an unformatted low-level error. The permissions side (claudecode-permissions.ts:127-135) already wraps the same parse in a try/catch that rethrows aFailed to parse existing Claude settings at <path>: <detail>message.Changes
JSON.parsein a try/catch that mirrors the permissions side, usingformatErrorfor a consistent, actionable message.settings.jsonthrows the formatted error.Scope note
Findings 1 and 2 of #2121 explicitly require no code change:
allow/ask/denyarrays now normalized away on the ignore path) is a documentation/changelog note — the behavior is intentional and already consistent with the permissions side.So this PR resolves the only actionable item and closes the issue.
Verification
pnpm cicheckpasses (6753 tests, including the new malformed-input test).Closes #2121
🤖 Generated with Claude Code