Restore pull-requests: write for claude-review - #91
Conversation
pull-requests was narrowed to read in #89 while fixing the OIDC failure, but that also silently disables posting reviews on same-repo PRs: the job runs and succeeds, but every write attempt is denied (confirmed via permission_denials_count in the job log) and no review ever appears. write is safe to restore here: this workflow uses the pull_request trigger (not pull_request_target), and GitHub always forces a read-only GITHUB_TOKEN for fork PRs regardless of what permissions: declares, so fork PRs stay read-only either way.
|
|
Confirming this, with evidence that strengthens the case: the bug is older than #89, so this is not a regression I introduced --- it is a defect I restored while claiming it was safe.
All four ran green. My reasoning in #89 was wrong and is worth correcting explicitly. I wrote that restoring Worth noting for the record: Copilot reviewed #89 twice and repeated my premise back approvingly. Two clean reviews on a false claim, because both of us reasoned about which token ought to post rather than checking whether a review had ever appeared. Your fork caveat is right --- GitHub forces a read-only One suggestion: this PR is the first chance to observe a genuine review on this repo. Its own |
|
One correction to the last point: this PR's own Since this PR's diff is Practical effect: we won't get the first genuine confirmation from this PR. It'll come from the next PR opened/updated after this one merges to Generated by Claude Code |
|
Withdrawing the suggestion at the end of my last comment. This PR cannot be the demonstration --- I should have predicted that from the mechanism I had just finished writing up. Because this PR edits the review workflow, its head no longer matches So the 0 The real test is the first same-repo PR pushed after this merges, with the workflow untouched: #76, #86, or #87. A Worth stating plainly, since the two failure modes now stack: a green |
pull-requests: write (UCD-SERG#91) fixed the GITHUB_TOKEN's API scope, but that's not what was blocking posting: permission_denials_count stayed high (and grew) because Claude Code's own tool-permission gate, which is separate from the token's API scope, was denying every attempt to call `gh pr comment` and mcp__github_inline_comment__create_inline_comment - the two mechanisms the code-review plugin actually uses to post a review. Neither is in Claude Code's default allowed-tools set for a non-interactive run, so every attempt was silently denied with nobody present to approve the prompt.
The code-review plugin gates all posting on a --comment argument: "If --comment argument was NOT provided, stop here. Do not post any GitHub comments." (step 7 of plugins/code-review/commands/code-review.md in anthropics/claude-code.) We have never passed it, so every review this repo has run has been working as designed -- reviewing, printing to the job log, and posting nothing behind a green check. claude has zero review comments across UCD-SERG#78, UCD-SERG#79, UCD-SERG#80, UCD-SERG#86, UCD-SERG#87, UCD-SERG#92, UCD-SERG#93 and UCD-SERG#94. This was not a permissions problem. UCD-SERG#91's pull-requests: write and UCD-SERG#92/UCD-SERG#94's allowlist work were treating a symptom. Closes UCD-SERG#96 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HMmB6db4xpbuqcqaQKArZb
- Stop dispatching a review for a fork PR. The reusable workflow's dispatch guard blocks forks, so dispatching posted ":mag: dispatched a review" and delivered nothing, with no red check to contradict it. Post an explicit fork notice linking #90 instead. - Add `pull-requests: read` to dispatch-on-comment. It calls `gh api repos/../pulls/N`, and declaring any scope zeroes the unlisted ones. - Document the three skip gates the reusable workflow adds (draft, fork, bot-sender) and the #84 red-to-gray interaction. - Correct three comments that asserted capabilities this repo does not have until #100 lands: claude.yml cannot dispatch a review, and `@claude review` does not produce one. - Restore the deleted rationale for `pull-requests: write` (#91) and for `--ref` on the dispatch. - State the inherited upstream defaults (report-cost, use-ai-config, lab-manual, require-review) instead of accepting them silently. - Document the exact accepted `/review` comment form. - Narrow the gha#437 and `secrets: inherit` claims to what each source says. Refs #101
Summary
claude-reviewjob's OIDC token-exchange failure by reverting the trigger frompull_request_targetback topull_request, and in the same change narrowedpermissions.pull-requestsfromwritetoread."permission_denials_count": 8andNo buffered inline comments— so no review ever appears on the PR, even though the check shows green.pull-requests: writeis safe: this workflow uses thepull_requesttrigger (notpull_request_target), and GitHub always forces a read-onlyGITHUB_TOKENfor PRs from forks regardless of whatpermissions:declares. So fork PRs stay read-only either way — this change only restores write access for same-repo PRs, which is the common case in this repo and where reviews were silently being dropped.Test plan
claude-reviewposts an actual review comment on a same-repo PR (e.g. re-run against PR Skip PR preview deploy for fork pull requests #87)Generated by Claude Code