Repository navigation
[OMNIML-6273] Let the Claude review bot submit its review again - #3156
Conversation
#3149 replaced Bash(gh pr review:*) with Bash(gh api repos/*/pulls/*/reviews:*) in the bot's allowed tools. A Bash rule ending in ":*" is a literal prefix, in which an inner "*" matches only itself, so the rule never matched "gh api repos/NVIDIA/Model-Optimizer/pulls/<N>/reviews ...". Since then the CLI has refused every review and approval with "This command requires approval". Spell the rule as this PR's reviews endpoint, from the workflow's REPO and PR_NUMBER, and expand the same endpoint in the prompt's two publish commands, so the command the bot is told to run is the one the rule admits. Tell the bot to run it as written: other spellings, such as "gh api -X POST <endpoint>" or "gh pr review", are refused. Signed-off-by: Shengliang Xu <shengliangx@nvidia.com>
|
/ok to test 732fb1a |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Restrict review submission commands .github/workflows/claude_review.yml |
The gh api allow-list and publishing instructions specify the current repository and pull request endpoint. The instructions require the endpoint to immediately follow gh api and disallow alternate command forms. |
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Bug fix
Possibly related PRs
- NVIDIA/Model-Optimizer#3149: Established the review-publication policy and API-based submission commands that this change updates.
Suggested reviewers: chenhanyu
Merge Risk: 
Minimal · up to 732fb
-
This change fixes the review bot's allow-list so it can publish reviews on the PR it was asked to review. The reported over-permissioning concern was disproved. Live validation is only possible after merge, because
issue_commentworkflows use the default branch's workflow file. That is normal uncertainty and not a merge blocker.
Pre-merge checks: 
6
-
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)
Full details: Security Anti-Patterns
-
Explanation
The pull request changes only
.github/workflows/claude_review.yml. It adds no Python changes under the ModelOpt package or examples, no dependency changes, and none of the listed security anti-patterns are introduced.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3156 +/- ##
=======================================
Coverage 80.34% 80.34%
=======================================
Files 675 675
Lines 77221 77221
=======================================
Hits 62042 62042
Misses 15179 15179
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
meenchen
left a comment
There was a problem hiding this comment.
Bot review (bedrock-claude-opus-5-5) — DM the bot to share feedback.
Approve: spelling out this PR's literal reviews endpoint in --allowedTools and in the prompt fixes the broken publish step. It also narrows what the bot can post to, and nothing that works today can break.
No action needed.
No action needed:
REPOandPR_NUMBERare job-levelenv(github.repository,github.event.issue.number). The samewith:block already expands${{ env.REPO }}in the prompt header, so theclaude_argsexpansion works. Neither value is attacker-controlled.- The prompt's publish commands now match the allow-list rule character for character. Before, the prompt wrote
$REPO/$PR_NUMBER, and the CLI checks the command text without expanding variables, so that form would not have matched. - The live check only happens after merge, because
issue_commentruns the workflow file from the default branch. Run/claude reviewon an open PR to confirm.
ChenhanYu
left a comment
There was a problem hiding this comment.
Automatic approval delegated by chenhany (mode: approve).
Pensieve approve review using chenhany's profile (revision 12).
Approve: /reviews prefixes match exactly; steps.with env-expansion, commit_id, head re-read, and policy are unchanged; follow-ups: unlisted pulls/<N>/comments re-review replies and draft #2977 rebasing (baseline d464d30b120254151309c217a8410adde6ee1c45; CLI unexecuted; history limited).
No action needed.
Review baseline: https://github.com/NVIDIA/Model-Optimizer/blob/d464d30b120254151309c217a8410adde6ee1c45/.agents/review-guidelines/code-review.md
Review run: 8bf09a86686f4f069ef45e705a154fe9
|
What does this PR do?
Type of change: Bug fix (CI workflow)
Since #3149 merged,
/claude reviewstill runs and reaches a verdict, but it can't publish it. The CLI refuses every review and approval the bot submits with "This command requires approval", and the run still ends green. Only inline comments get through.Root cause. #3149 replaced
Bash(gh pr review:*)withBash(gh api repos/*/pulls/*/reviews:*)in--allowedTools. A Bash rule ending in:*is a literal prefix, in which an inner*matches only itself. So the rule never matched the command the prompt prescribes,gh api repos/NVIDIA/Model-Optimizer/pulls/<N>/reviews --method POST .... Withgh pr reviewgone, the bot had no other way to post. These runs show it (search the log forpermission_denied):gh api -X POST ...and asgh pr review --approve.Fix.
REPOandPR_NUMBER:Bash(gh api repos/${{ env.REPO }}/pulls/${{ env.PR_NUMBER }}/reviews:*). Actions expands the expressions before the action readsclaude_args, so the CLI gets a literal prefix. The bot can review only the PR it was asked to review, which is narrower than bothgh pr review:*and the wildcard ci: establish a shared review baseline and adopt it in Claude reviews #3149 intended.commit_idpin, the head re-read before publishing, and the publishing policy.Usage
No change: comment
/claude reviewon a PR.Testing
issue_commentworkflows run the default branch's workflow file, so this change can run live only after it merges. After that, a/claude reviewon any open PR should land a review or an approval.Checked locally:
e4a6faad497d(v1.0.255), the pinned version, installs Claude Code 2.1.305:claudeCodeVersionis set insrc/entrypoints/run.ts, and the run logs printInstalling Claude Code v2.1.305.ghit ran./ghx, a stand-in script that only prints its arguments.echocan't be used here because the CLI auto-allows it as a read-only command.--allowedToolsrule./ghx api repos/NVIDIA/Model-Optimizer/pulls/2779/reviews --method POST -f event=COMMENT./ghx api -X POST repos/NVIDIA/Model-Optimizer/pulls/2779/reviews -f event=COMMENT./ghx hello(control)Bash(./ghx api repos/*/pulls/*/reviews:*)(as on main)Bash(./ghx api repos/NVIDIA/Model-Optimizer/pulls/2779/reviews:*)(this PR, expanded)--allowedToolslist, also lets realistic bodies through on 2.1.305: multi-line single-quoted bodies with backticks,'"'"'apostrophes and</>, and double-quoted bodies with escaped backticks.#("Newline followed by # inside a quoted argument"). That check predates ci: establish a shared review baseline and adopt it in Claude reviews #3149, and the shared baseline's summary format allows no headings.Before your PR is "Ready for review"
CONTRIBUTING.md: N/A/claude reviewcan't publish until this fix is on main)Additional Information
.github/workflows/claude_review.yml.gh api repos/<repo>/pulls/<N>/comments. That was never on the allow-list, before ci: establish a shared review baseline and adopt it in Claude reviews #3149 either, so on a re-review it can't see replies in earlier threads.Summary by CodeRabbit