Surface line and column for malformed settings JSON#1273
Open
SalihMor1na wants to merge 1 commit intoanthropics:mainfrom
Open
Surface line and column for malformed settings JSON#1273SalihMor1na wants to merge 1 commit intoanthropics:mainfrom
SalihMor1na wants to merge 1 commit intoanthropics:mainfrom
Conversation
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.
Addresses #242 (JSON parsing portion only).
When
.claude/settings.jsonor thesettings:action input contains malformed JSON, the action either silently swallows the error or logs a misleading "no existing settings file found" message. This adds a smallparseJsonWithLocationhelper that re-throwsJSON.parsefailures with the source identifier and 1-based line/column.Note on #587: I noticed @linus-amg has an open PR (#587) addressing the same issue with a Zod schema validation approach. This PR is intentionally narrower and complementary:
setup-claude-code-settings.tswhere a malformed existing settings file is silently mis-reported as "no existing settings file found"Happy to close this in favor of #587, combine approaches, or proceed independently — whichever maintainers prefer.
Scope: intentionally narrow. No content from the parsed file is included in error messages, so secrets in settings files cannot leak into action logs.
Behavior changes:
~/.claude/settings.jsonnow throws with line/column instead of being silently treated as missing.settings:JSON input now throws with line/column instead of being silently re-interpreted as a file path.ALL_INPUTSparse failures now produce acore.warningannotation with line/column. Still returns{}to preserve existing non-fatal behavior.Tests: 7 new unit tests in
base-action/test/validate-json.test.ts. Full suite (672 tests) passes locally.bun run typecheckandbun run format:checkclean.GitHub Actions workflow YAML validation (the other half of #242) is not addressed here — by the time the action runs, GitHub has already parsed the workflow YAML, so that piece would need a different mechanism (e.g., a separate validator script users run pre-commit).