Widen claude-code-review's allowedTools to what the plugin actually needs - #98
jnasbyupgrade wants to merge 3 commits into
Conversation
…eeds Every run of the automated code-review job completes successfully but never posts a review: the `/code-review` plugin's own steps launch haiku/sonnet/opus subagents (Task) to do the actual analysis and read PR data via `gh pr diff`, `gh pr view`, etc., but claude_args' --allowedTools only granted mcp__github_inline_comment__create_inline_comment plus baseline read/git-write tools -- neither Task nor any gh subcommand was in the effective allowlist, so every attempt to use them was silently denied until the run gave up. Add exactly the Bash(gh ...) subcommands the plugin's own allowed-tools frontmatter declares (commands/code-review.md in anthropics/claude-code@main), plus Task for its subagent architecture -- verified against the SDK's own allowedTools dump and permission_denials_count in two runs that reached "success" without posting anything. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @jnasbyupgrade's task in 3m 11s —— View job Review: widen
|
claude_args reaches claude-code-action as a bare string that it re-tokenizes with the shell-quote npm package, which splits on whitespace. The previous commit's unquoted, comma-joined list broke on the spaces inside every Bash(gh ...) entry, so none of those seven grants actually survived intact -- subagents could launch but every gh pr diff/view/comment call was still denied, reproducing the original bug for a different reason. Wrapping the whole value in double quotes keeps it as one token; verified against the actual shell-quote package mirroring claude-code-action's own parsing logic. Also add TodoWrite: the plugin's Notes unconditionally say to create a todo list before starting, and that tool isn't in the action's baseline set either. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
State the actual non-obvious fact directly: YAML's own quotes never reach claude-code-action, so the inner double quotes around --allowedTools aren't redundant even though the line already looks quoted.
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
Widens
.github/workflows/claude-code-review.yml'sclaude_args--allowedToolsto the tools the/code-reviewplugin actually needs —Taskfor the subagents its steps launch to do the review,TodoWritefor the todo list its Notes require, and the sevenBash(gh ...)subcommands its ownallowed-toolsfrontmatter declares for reading PR data and posting a no-issues summary — and wraps the whole value in double quotes so it survivesclaude-code-action'sshell-quote-based re-tokenization as one token instead of splintering on the spaces inside eachBash(gh ...)entry.Verification of the actual review behavior is outstanding. Per
.github/workflows/CLAUDE.md, apull_request_targetworkflow always runs from the base branch's copy of the file, never the PR's own — so this PR's ownclaude-reviewcheck runs master's old, still-broken version and cannot prove anything either way. The tokenization fix below is independently verified (see next section); only "does the plugin's review now actually complete and post findings" remains to be confirmed after merge, on the next real PR.What was broken and how it's confirmed fixed
The action's
allowedTools/allowed-toolsinputs are an allowlist, not additive to a sane default: any plugin tool call not named there is silently denied. The previous state of this file granted onlymcp__github_inline_comment__create_inline_commentplus the action's baseline read/git-write tools — noTask, noghsubcommand — so the plugin's subagents and its PR-data reads were denied on every run, and the run ended having posted nothing.The observed SDK
allowedToolsarray on two runs that reported"subtype": "success"without posting a review was exactly:Glob, Grep, LS, Read, mcp__github_comment__update_claude_comment, mcp__github_ci__get_ci_status, mcp__github_ci__get_workflow_run_details, mcp__github_ci__download_job_log, mcp__github_inline_comment__create_inline_comment, Bash(git add:*), Bash(git commit:*), Bash(.../git-push.sh:*), Bash(git rm:*). Thecode-reviewplugin's own source (anthropics/claude-code@main,plugins/code-review/commands/code-review.md) declaresallowed-tools: Bash(gh issue view:*), Bash(gh search:*), Bash(gh issue list:*), Bash(gh pr comment:*), Bash(gh pr diff:*), Bash(gh pr view:*), Bash(gh pr list:*), mcp__github_inline_comment__create_inline_comment, and its numbered steps launch haiku/sonnet/opus subagents (Task) to do the review and validation work — none of that was in the effective allowlist.claude_argsreachesclaude-code-actionas a bare string that it re-tokenizes with theshell-quotenpm package (base-action/src/parse-sdk-options.ts'sparseClaudeArgsToExtraArgs, mirrored bysrc/modes/agent/parse-tools.ts'sparseAllowedTools), which splits on whitespace — the spaces inside eachBash(gh ...)entry break it into multiple garbage tokens unless the whole value is one quoted token. Verified directly against the realshell-quotepackage by reproducing both functions' logic:Unquoted (the obvious-looking form):
Quoted (current), parsed from the literal
claude_argsstring read out of the committed YAML:Bashotherwise stays scoped to the pre-existing git write commands (add/commit/push/rm); nothing broader was added, andTaskdoes not widen what a subagent can do — tool permissions are enforced per call regardless of which agent makes it.🤖 Generated with Claude Code