Skip to content

fix: replace shell-quote with literal arg splitter to handle # in claude_args values#982

Closed
Mellowambience wants to merge 1 commit into
anthropics:mainfrom
Mellowambience:fix/shell-quote-hash-comment-bug
Closed

fix: replace shell-quote with literal arg splitter to handle # in claude_args values#982
Mellowambience wants to merge 1 commit into
anthropics:mainfrom
Mellowambience:fix/shell-quote-hash-comment-bug

Conversation

@Mellowambience
Copy link
Copy Markdown

Fixes #980

Problem

shell-quote's parse() treats # as a shell comment character, returning a {comment: "..."} object instead of a string. The .filter(arg => typeof arg === "string") call drops this object, leaving the preceding flag with no value. The parser then sets that flag to null, which fails AJV schema validation and crashes the action before any API call is made.

Reproduction:

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

append-system-prompt: null → AJV validation crash

Solution

Replace shell-quote with a purpose-built splitArgString() that:

  • Splits on whitespace
  • Respects double-quoted strings (spaces inside quotes preserved)
  • Never interprets shell metacharacters#, !, ~, $ are all treated as literal characters

claude_args is a list of CLI flags, not a shell command. There's no reason for # to be interpreted as a comment.

Changes

  • base-action/src/parse-sdk-options.ts: Add splitArgString(), replace parseShellArgs(claudeArgs).filter(...) with splitArgString(claudeArgs)

Workaround for users (until merged)

Double-quote values containing #:

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

Testing

Manually verified against the reproduction case. Happy to add unit tests to the test suite if you can point me to the right test file — I see __tests__/ referenced but wasn't sure of the exact conventions here.

Fixes anthropics#980

shell-quote's parse() treats # as a shell comment character, returning a
{comment: '...'} object. The .filter(arg => typeof arg === 'string') call
drops this, leaving the preceding flag with no value. The parser then sets
that flag to null, which fails AJV schema validation and crashes the action.

Replacement: splitArgString() splits on whitespace, respects double-quoted
strings, and never interprets shell metacharacters. claude_args is a list
of CLI flags, not a shell command — # should never be treated as a comment.
@Mellowambience
Copy link
Copy Markdown
Author

Hi, just checking in on this PR — wanted to make sure it hadn't slipped through the cracks. Happy to rebase, add tests, or make any changes needed to move it forward. Thanks for your time!

@Mellowambience
Copy link
Copy Markdown
Author

pinging for review — shell-quote treats # as a shell comment character, causing any argument containing # (common in hex colors, issue refs, markdown fragments) to be silently dropped. this PR replaces the parse step with a literal splitter that preserves # correctly. small change, clear fix, well-scoped to the bug in #980.

@Mellowambience
Copy link
Copy Markdown
Author

Hi! It's been about 5 days since any activity on this fix. The # parsing bug in claude_args is still reproducible — would love to get eyes on this when you have a moment. Happy to rebase or adjust if needed. Thanks!

@ashwin-ant
Copy link
Copy Markdown
Collaborator

Closing in favor of #1055

@ashwin-ant ashwin-ant closed this Apr 5, 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.

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

2 participants