Skip to content

fix: strip shell comment lines before parsing claude_args#1055

Open
VoidChecksum wants to merge 1 commit intoanthropics:mainfrom
VoidChecksum:fix/strip-shell-comments-before-parsing
Open

fix: strip shell comment lines before parsing claude_args#1055
VoidChecksum wants to merge 1 commit intoanthropics:mainfrom
VoidChecksum:fix/strip-shell-comments-before-parsing

Conversation

@VoidChecksum
Copy link

Summary

  • The shell-quote library treats # as a shell comment character, causing all content after a # (including subsequent flags on new lines) to be silently swallowed
  • Users adding documentation comments to their claude_args YAML inadvertently break flag parsing
  • Fix: strip full comment lines (lines starting with #) before passing input to shell-quote

Before

claude_args: |
  --model 'claude-haiku-4-5'
  # This is a comment
  --allowed-tools 'mcp__github_inline_comment__create_inline_comment'

--allowed-tools is silently dropped — shell-quote puts it inside a comment object.

After

Comment lines are stripped before parsing, so both --model and --allowed-tools are correctly parsed. Inline # within quoted values (e.g., --prompt 'use color #ff0000') is preserved.

Changes

  • base-action/src/parse-sdk-options.ts: Add stripShellComments() function, apply before parseShellArgs()
  • base-action/test/parse-sdk-options.test.ts: Add 3 test cases covering comments, no comments, and inline # in values

Test plan

  • Test: flags before and after comment line are both parsed
  • Test: no-comment input still works
  • Test: inline # in quoted values is NOT stripped
  • Manual test with GitHub Actions workflow using comment-containing claude_args

Fixes #802

shell-quote treats # as a shell comment character, swallowing all
subsequent content including flags on new lines. Strip comment lines
(lines starting with #) before passing input to shell-quote.

Fixes anthropics#802
Copilot AI review requested due to automatic review settings March 16, 2026 11:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a parsing bug where shell-quote interprets # as a comment delimiter and can swallow subsequent flags in multiline claudeArgs. The fix preprocesses the argument string by removing full comment lines before invoking shell-quote, and adds tests to cover the behavior.

Changes:

  • Add stripShellComments() to remove lines whose first non-whitespace character is # before parsing.
  • Apply comment stripping in parseClaudeArgsToExtraArgs() prior to calling shell-quote.
  • Add unit tests to verify flags around comment lines still parse and inline # in quoted values is preserved.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
base-action/src/parse-sdk-options.ts Strips full-line # comments before shell-quote parsing to prevent later flags from being swallowed.
base-action/test/parse-sdk-options.test.ts Adds regression tests for comment-line stripping and preserving inline # inside quoted values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

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 # as comment, swallowing all subsequent flags in claude_args

2 participants