Skip to content

Parser error with variable substitution in bash script analysis #888

@aiKrice

Description

@aiKrice

Describe the bug
The Claude Code SDK fails to parse valid bash syntax during script analysis in GitHub Actions, throwing a "Bad substitution: all_badges:+" error. The same bash code
works perfectly when executed locally.

To Reproduce
Steps to reproduce the behavior:

  1. Create a bash script with this variable assignment:
    all_badges="${ready_for_approval_badge} ${all_badges}"
  2. Set up a GitHub Action workflow using anthropics/claude-code-action@v1
  3. Configure Claude to review the code
  4. Run the workflow
  5. See error: Error: Bad substitution: all_badges:+

Expected behavior
The SDK should successfully parse this valid bash syntax. The expression all_badges="${ready_for_approval_badge} ${all_badges}" is standard bash variable expansion
and should not cause parsing errors.

Screenshots
Error: Bad substitution: all_badges:+
at P (/home/runner/work/_actions/anthropics/claude-code-action/v1/base-action/node_modules/@anthropic-ai/claude-agent-sdk/cli.js:66:3347)
at (/home/runner/work/_actions/anthropics/claude-code-action/v1/base-action/node_modules/@anthropic-ai/claude-agent-sdk/cli.js:66:4002)
at map (native:1:11)
at u1K (/home/runner/work/_actions/anthropics/claude-code-action/v1/base-action/node_modules/@anthropic-ai/claude-agent-sdk/cli.js:66:3089)
...
Error: Failed to parse command: Bad substitution: all_badges:+
at BB1 (/home/runner/work/_actions/anthropics/claude-code-action/v1/base-action/node_modules/@anthropic-ai/claude-agent-sdk/cli.js:4796:117)

Workflow yml file
name: Claude Code Review

on:
workflow_call:
inputs:
pr_number:
required: true
type: number
pr_author:
required: true
type: string
head_ref:
required: true
type: string
secrets:
CLAUDE_CODE_OAUTH_TOKEN:
required: true

jobs:
claude-review:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login != 'dependabot[bot]'

  steps:
    - name: Checkout code
      uses: actions/checkout@v4
      with:
        ref: ${{ inputs.head_ref }}
        fetch-depth: 0

    - name: Claude Code Review
      uses: anthropics/claude-code-action@v1
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        anthropic_api_key: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
        prompt_file: .github/claude-review-prompt.md

API Provider

  • Anthropic First-Party API (default)

    Additional context

    • The bash script (badgetizr) runs successfully locally with bash badgetizr --help
    • All 181 bats tests pass locally: make test succeeds
    • ShellCheck validation passes: no syntax errors reported
    • The problematic line is standard bash variable concatenation
    • The SDK appears to internally generate ${all_badges:+...} syntax during parsing, which then fails
    • This only affects CI/CD environments using the GitHub Action, not local execution

Minimal reproducible example:

  #!/bin/bash
  all_badges=""
  ready_for_approval_badge="test"
  all_badges="${ready_for_approval_badge} ${all_badges}"  # This line causes SDK parsing error
  echo "$all_badges

This valid bash code triggers the parsing error in Claude Code SDK but executes correctly in any bash shell.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2Non-showstopper bug or popular feature requestprovider:1pAnthropic First-Party API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions