Skip to content

fix: handle shell-quote treating # as comment in claude_args#988

Open
yoheidemachi wants to merge 2 commits intoanthropics:mainfrom
yoheidemachi:fix/shell-quote-hash-comment
Open

fix: handle shell-quote treating # as comment in claude_args#988
yoheidemachi wants to merge 2 commits intoanthropics:mainfrom
yoheidemachi:fix/shell-quote-hash-comment

Conversation

@yoheidemachi
Copy link

shell-quote's parse() treats # as the start of a shell comment and returns {comment: "..."} objects instead of strings. The existing .filter(arg => typeof arg === 'string') drops these objects, leaving the preceding flag with no value (null). This null propagates into the SDK config and triggers an AJV schema validation crash.

Changes

  • Convert {comment: "..."} objects back to strings (prepending #) instead of dropping them
  • Add test cases for # in quoted and unquoted flag values

Reproduction (before fix)

claude_args: |
  --append-system-prompt \#\ Use\ best\ practices

Crashes with AJV validation error because append-system-prompt receives null.

Closes #980

yoheidemachi and others added 2 commits March 1, 2026 10:56
shell-quote's parse() returns {comment: "..."} objects when it encounters
# characters, even inside flag values. The existing filter dropped these
objects, causing the flag to receive a null value and triggering an AJV
schema validation crash.

Convert comment objects back to strings (prepending #) instead of
dropping them, so values like "# Use best practices" are preserved.

Fixes anthropics#980

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

shell-quote treats # in claude_args values as comments, causing null values and AJV crash

1 participant