Skip to content

fix(settings): improve settings input validation and error diagnostics - #1689

Open
Juwan-Hwang wants to merge 1 commit into
anthropics:mainfrom
Juwan-Hwang:fix/settings-input-diagnostics
Open

fix(settings): improve settings input validation and error diagnostics#1689
Juwan-Hwang wants to merge 1 commit into
anthropics:mainfrom
Juwan-Hwang:fix/settings-input-diagnostics

Conversation

@Juwan-Hwang

Copy link
Copy Markdown
Contributor

Summary

This PR improves input parsing, error handling, and diagnostic reporting in \setupClaudeCodeSettings\ (\�ase-action/src/setup-claude-code-settings.ts).

Problems Addressed

  1. Misleading Error Reporting on Malformed JSON:
    Previously, if a workflow author supplied an inline JSON string that contained a syntax error (such as a missing bracket, quote, or trailing comma), \JSON.parse\ failed and the loader immediately fell back to treating the entire string as a filesystem path. When
    eadFile\ failed, an obscure \ENOENT: no such file or directory, open '{...'\ error was raised instead of reporting the actual JSON syntax error.
  2. Missing Dictionary Object Type Guard:
    \JSON.parse\ can successfully parse non-object primitives or arrays (e.g. [1, 2, 3]\ or \123), which were then shallowly merged via { ...settings, ...inputSettings }\ without validating that \inputSettings\ is a valid object dictionary.
  3. Defensive Input Handling:
    Introduced clean separation between inline JSON strings (detected via syntax prefix) and configuration file paths, providing precise diagnostic messages for:
    • Inline JSON syntax errors
    • Missing configuration files
    • Malformed JSON in configuration files
    • Non-dictionary configuration formats

Changes

  • Extracted and exported \parseSettingsInput\ helper function in \�ase-action/src/setup-claude-code-settings.ts.
  • Added precise diagnostic error messages for inline JSON syntax errors and missing/invalid file paths.
  • Added type validation to enforce that parsed settings evaluate to a non-null, non-array object dictionary.
  • Expanded test coverage in \�ase-action/test/setup-claude-code-settings.test.ts\ to verify inline JSON errors, file parsing errors, and non-object inputs.

Verification

  • Verified all existing and new unit tests for \setupClaudeCodeSettings\ and \parseSettingsInput.
  • Formatted with Prettier.

- Distinguish inline JSON from configuration file paths deterministically using syntax heuristics and filesystem resolution.

- Provide clear, actionable syntax error messages when inline JSON is malformed instead of falling back to misleading file-not-found errors.

- Validate that parsed settings conform to a JSON dictionary object (rejecting primitives and arrays).

- Expand unit tests to cover malformed JSON, invalid schemas, and file error cases.
Copilot AI lite review requested due to automatic review settings August 17, 2026 23:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants