Skip to content

refactor(ignore): guard ignore-side Claude settings JSON.parse with try/catch - #2126

Merged
dyoshikawa merged 1 commit into
mainfrom
resolve-issue-2121-ignore-json-parse-guard
Jul 6, 2026
Merged

refactor(ignore): guard ignore-side Claude settings JSON.parse with try/catch#2126
dyoshikawa merged 1 commit into
mainfrom
resolve-issue-2121-ignore-json-parse-guard

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Background

Follow-up from the review of PR #2115 (captured in #2121). Finding 3: the Claude Code ignore feature parsed an existing .claude/settings.json with a bare JSON.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 a Failed to parse existing Claude settings at <path>: <detail> message.

Changes

  • Wrap the ignore-side JSON.parse in a try/catch that mirrors the permissions side, using formatError for a consistent, actionable message.
  • Add a unit test asserting a malformed existing settings.json throws the formatted error.

Scope note

Findings 1 and 2 of #2121 explicitly require no code change:

  • Finding 1 (empty/null allow/ask/deny arrays now normalized away on the ignore path) is a documentation/changelog note — the behavior is intentional and already consistent with the permissions side.
  • Finding 2 (Reasonix DRY) is a conditional future follow-up, only relevant if the same gateway centralization is ever applied to Reasonix.

So this PR resolves the only actionable item and closes the issue.

Verification

pnpm cicheck passes (6753 tests, including the new malformed-input test).

Closes #2121

🤖 Generated with Claude Code

…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>
@dyoshikawa
dyoshikawa merged commit fe7b9f8 into main Jul 6, 2026
9 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner Author

@dyoshikawa Thank you!

@dyoshikawa
dyoshikawa deleted the resolve-issue-2121-ignore-json-parse-guard branch July 6, 2026 09:07
@dyoshikawa dyoshikawa mentioned this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-ups from PR #2115 review: document empty-array normalization, Reasonix DRY, and ignore-side JSON.parse try/catch

2 participants