Skip to content

fix: parse ALL --allowed-tools flags, not just the first one - #801

Merged
ashwin-ant merged 1 commit into
anthropics:mainfrom
AlexanderBartash:fix-parse-all-allowed-tools-flags
Jan 8, 2026
Merged

fix: parse ALL --allowed-tools flags, not just the first one#801
ashwin-ant merged 1 commit into
anthropics:mainfrom
AlexanderBartash:fix-parse-all-allowed-tools-flags

Conversation

@AlexanderBartash

Copy link
Copy Markdown
Contributor

Summary

Fixes #800

The parseAllowedTools() function previously used .match() which only returns the first match. This caused tools specified in subsequent --allowed-tools flags to be ignored during MCP server initialization.

Changes

  • Add /g flag to regex patterns for global matching
  • Use matchAll() to find all occurrences
  • Deduplicate tools while preserving order
  • Make unquoted pattern not match quoted values (to avoid capturing quotes from quoted patterns)

Root Cause

When users specify multiple --allowed-tools flags:

claude_args: |
  --allowed-tools 'mcp__context7__*'
  --allowed-tools 'Read,Glob,Grep'
  --allowed-tools 'mcp__github_inline_comment__create_inline_comment'

Only tools from the first flag were parsed. This broke MCP server initialization when mcp__github_* tools weren't in the first flag.

Test plan

  • All existing tests pass
  • Added new tests for multiple --allowed-tools flags
  • Added test for deduplication across flags
  • Added test for multiline flag parsing

The parseAllowedTools() function previously used .match() which only
returns the first match. This caused tools specified in subsequent
--allowed-tools flags to be ignored during MCP server initialization.

Changes:
- Add /g flag to regex patterns for global matching
- Use matchAll() to find all occurrences
- Deduplicate tools while preserving order
- Make unquoted pattern not match quoted values

Fixes anthropics#800

 #vibe

Co-authored-by: Claude <noreply@anthropic.com>
@ashwin-ant
ashwin-ant merged commit 005436f into anthropics:main Jan 8, 2026
4 of 21 checks passed
@AlexanderBartash
AlexanderBartash deleted the fix-parse-all-allowed-tools-flags branch January 8, 2026 20:11
@sachinmahale

Copy link
Copy Markdown

@AlexanderBartash after this v1.0.30 our workflow is now failing.

here is the workflow:

      - name: 🤖 Run Claude Code Review (via Bedrock)
        uses: anthropics/claude-code-action@v1
        with:
          # Use the default token for GitHub interaction (comments, file reading)
          github_token: ${{ secrets.GITHUB_TOKEN }}

          # Flag to enable AWS Bedrock integration
          use_bedrock: true

          # Enable progress tracking for visual feedback on the PR
          track_progress: true

          # The comprehensive instruction prompt for Claude
          prompt: |
            REPO: ${{ github.repository }}
            PR NUMBER: ${{ github.event.pull_request.number }}

            Perform a comprehensive code review with the following focus areas:

            1. **Code Quality**
               - Clean code principles and best practices
               - Proper error handling and edge cases
               - Code readability and maintainability

          claude_args: |
            # Defines the tools Claude is allowed to use for the review
            --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(cat:AGENTS.md),Bash(cat:@AGENTS_my_custom_rules.md)"
            # Set max-turns higher for large/complex PRs to avoid premature termination
            --max-turns 75

we are getting below error:

SDK execution error: 7835 |       throw error;
7836 |     }
7837 |   }
7838 |   getProcessExitError(code, signal) {
7839 |     if (code !== 0 && code !== null) {
7840 |       return new Error(`Claude Code process exited with code ${code}`);
                    ^
error: Claude Code process exited with code 1
      at getProcessExitError (/home/runner/work/_actions/anthropics/claude-code-action/v1/base-action/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs:7840:14)
      at exitHandler (/home/runner/work/_actions/anthropics/claude-code-action/v1/base-action/node_modules/@anthropic-ai/claude-agent-sdk/sdk.mjs:7970:28)
      at emit (node:events:92:22)
      at #handleOnExit (node:child_process:511:14)

@AlexanderBartash

Copy link
Copy Markdown
Contributor Author

@sachinmahale Comments are not allowed in the claude_args: | I have a separate fix for that #803 I think it never worked with comments, even before my changes because I also tried adding them and it failed, that is why the fix.

@sachinmahale

Copy link
Copy Markdown

@AlexanderBartash I tried removing complete claude_args: block, still its not working.

@AlexanderBartash

AlexanderBartash commented Jan 19, 2026

Copy link
Copy Markdown
Contributor Author

@sachinmahale The changes in PR #801 only affect the parsing of --allowed-tools flags. When claude_args is empty, the behavior is identical to before (returns an empty array). So it cannot be the cause of the error. I recomment trying different action versions to see which one broke it.

@AlexanderBartash

Copy link
Copy Markdown
Contributor Author

@sachinmahale E.g. use_bedrock: true I think requires id-token: write permission, also aws-actions/configure-aws-credentials and --model in claude_args.

@sachinmahale

sachinmahale commented Jan 19, 2026

Copy link
Copy Markdown

@AlexanderBartash our workflow was working fine till 16th Jan. but after the release v1.0.30 it started failing.
I changed the action from anthropics/claude-code-action@v1 to anthropics/claude-code-action@v1.0.28 and it started working again.
You can go through our workflow and let me know your change is causing the problem.
Also please be noted that in our all repos AGENTS.mg is present and its being respected through Bash(cat:AGENTS.md) in claude_args, like I said, I removed complete claude_args block but still workflow fails if I use v1.

@AlexanderBartash

Copy link
Copy Markdown
Contributor Author

@sachinmahale Between 30 and 28 there is also 29 :) I cannot really help you because I do not see your workflow logs, nor your full workflow. I already provided feedback based on what you gave me.

@AlexanderBartash

Copy link
Copy Markdown
Contributor Author

@sachinmahale Please read my messages properly. I am not sure that you can remove claude_args while using bedrock due to needing --model. I may be wrong.