Repository navigation
ci: run the Claude review on pull_request_target - #6398
Merged
Merged
Conversation
rene
marked this pull request as ready for review
August 24, 2026 16:09
Contributor
Author
|
@eriknordmark , It doesn't cover all possibilities, but I tested on my repo with the following PRs: |
rene
force-pushed
the
fix-claude-review-fork-oidc
branch
from
August 25, 2026 13:53
39a3bc4 to
5d80d73
Compare
rene
marked this pull request as draft
August 25, 2026 14:38
rene
force-pushed
the
fix-claude-review-fork-oidc
branch
from
August 25, 2026 14:43
6fe906e to
fe50f46
Compare
rene
marked this pull request as ready for review
August 25, 2026 15:05
Every PR to this repo is opened from a fork. A "pull_request" run on a fork PR gets a read-only GITHUB_TOKEN and no access to secrets, so the id-token: write permission the workflow requests is dropped and claude-code-action fails while fetching its OIDC token: Could not fetch an OIDC token. Did you remember to add `id-token: write` to your workflow permissions? The failure was invisible until now because the job's author_association gate is evaluated against the webhook payload, which reports MEMBER only for users whose lf-edge membership is public. For everyone else the job was skipped before it could fail, so the breakage looked specific to the handful of public members. Switch the PR trigger to pull_request_target, which runs in the base repo context with the token and secrets the action needs. The checkout stays on the base ref and the review reads the diff over the API, so no PR-controlled content is executed or interpolated into a shell. Record the trigger in the zizmor dangerous-triggers ignore list with the same rationale the other privileged workflows carry. Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A pull_request_review_comment on a PR from a fork runs in the same
restricted context as pull_request: a read-only GITHUB_TOKEN and no
secrets. The reviewer cannot work there — it gets an empty
anthropic_api_key and 403s on its own tracking comment:
HttpError: Resource not accessible by integration
- .../rest/issues/comments#create-an-issue-comment
Unlike pull_request there is no _target variant of the event to move to,
and every PR to this repo comes from a fork, so this trigger can never
do anything useful here. Worse, the gate never checked the comment body,
so it would have fired the reviewer on every inline comment left by a
user with write access.
Drop it. @claude from the Conversation tab is an issue_comment, which
runs in the base repo context with the token and secrets the action
needs, and is the only path that has ever completed a review here.
Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributors without write access on this repo cannot use the reviewer at all today. The job's gate skips them, and even when it does not the action fails in the app-token exchange: App token exchange failed: 401 Unauthorized - User does not have write access on this repository Accept CONTRIBUTOR in the issue_comment branch of the gate, so anyone who has already had a commit merged here can ask for a review with @claude. The pull_request_target branch is deliberately left alone: opening or pushing to a PR still only auto-triggers a review for people with write access, which keeps drive-by pushes from spending API credit. Passing github_token makes the action use the workflow token instead of exchanging an OIDC token for an app token, which is what enforced write access; allowed_non_write_users then stops it re-checking write access on its own. Reviews are posted by github-actions[bot] rather than claude[bot] as a result. id-token: write is dropped, as nothing requests an OIDC token any more. Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
rene
force-pushed
the
fix-claude-review-fork-oidc
branch
from
August 25, 2026 15:06
fe50f46 to
9805a69
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Three fixes to
.github/workflows/claude-review.yml, one commit each.Context for all three: since this workflow landed (
7dfbb932d, 2026-05-07) it has produced 3254 runs, and not onepull_requestorpull_request_review_commentrun has ever succeeded. Every success is anissue_comment(@claude) run, and every actor with a successful run holds write or admin on this repo.1.
ci: run the Claude review on pull_request_targetThe review fails on every PR where it actually runs. Example: run 32717278432 on #6395.
Every PR to this repo is opened from a fork. For a
pull_requestevent on a fork PR, GitHub gives the job a read-onlyGITHUB_TOKENand no access to secrets, so theid-token: writethe workflow requests is silently dropped andclaude-code-actiondies insetupGitHubToken.secrets.ANTHROPIC_API_KEYis empty in that context too, so the run could not have succeeded even past the OIDC step.The failure was mostly invisible because
author_associationin apull_requestpayload does not resolve the same way it does in anissue_commentpayload — of everyone who has opened a PR recently, only PRs from a public member of thelf-edgeorg cleared the gate at all, so for everyone else the job was skipped before it could fail.Switch the PR trigger to
pull_request_target, which runs in the base repo context with the token and secrets the action needs.Security notes, since
pull_request_targetis a privileged trigger:ref, so it stays on the base ref — the PR head is never checked out.github.repositoryand the PR number are, and the review reads the diff over the API.claude-review.ymlis added to thedangerous-triggersignore list in.github/zizmor.yml, with the same kind of documented rationale the other privileged workflows there carry.2.
ci: drop the review-comment trigger from the Claude reviewA
pull_request_review_commenton a PR from a fork runs in the same restricted context aspull_request: a read-onlyGITHUB_TOKENand no secrets. Verified on a fork PR against a copy of this repo — the action gets an emptyanthropic_api_keyand 403s on its own tracking comment before Claude ever runs:Unlike
pull_requestthere is no_targetvariant of the event to move to, and every PR to this repo comes from a fork, so the trigger can never do anything useful here. It was also a footgun: its branch of the gate never checked the comment body, so it would have fired the reviewer on every inline comment left by a user with write access.Drop it.
@claudefrom the Conversation tab is anissue_comment, which runs in the base repo context with the token and secrets the action needs, and is the only path that has ever completed a review here.3.
ci: let contributors invoke the Claude review with @claudeContributors without write access cannot use the reviewer at all. The gate skips them, and when it does not, the action fails in the app-token exchange:
(see runs 30625682479 / 30638902574 on #6188, and #6354 for the skipped case). This affects real reviewers here —
christoph-zededa,europaul,naiming-zededaandandrewd-zededaall have read-only access to this repo.Accept
CONTRIBUTORin theissue_commentbranch of the gate, so anyone with a merged commit here can ask for a review with@claude. Thepull_request_targetbranch is deliberately left alone: opening or pushing to a PR still auto-triggers a review only for people with write access, so a contributor pushing to a long-running PR does not spend API credit on every commit.Mechanically that needs two inputs, since either alone is inert:
github_token: ${{ secrets.GITHUB_TOKEN }}makes the action use the workflow token instead of exchanging an OIDC token for an app token — the exchange being what enforces write access.allowed_non_write_users: "*"stops the action re-checking write access itself. The job'sif:condition is the real allowlist; a user with no merged commit isNONE/FIRST_TIME_CONTRIBUTORand never reaches the action.Consequences worth knowing before approving:
github-actions[bot]rather thanclaude[bot], for everyone, since the app is no longer in the loop.id-token: writeis dropped frompermissions:, as nothing requests an OIDC token any more. Keeping the token minimal is the main mitigation here: the reviewer can now be invoked by people without write access, so the permissions it holds bound what a prompt injected through a diff could do.How to test and validate this PR
pull_request_targetalways uses the workflow definition from the base branch, so this PR cannot exercise the new trigger itself — validation of items 1 and 3 has to happen after merge.actionlintandyamllintare clean, and the Zizmor job should stay green (thedangerous-triggersfinding is suppressed by the new.github/zizmor.ymlentry; the pre-existingunpinned-usesfinding onanthropics/claude-code-action@v1is unchanged and non-fatal).Claude Coderun should complete and post its review instead of failing withCould not fetch an OIDC token.Claude Coderun is created at all.@christoph-zededa) comment@claudein the Conversation tab of a PR, and confirm it produces a review rather than a skipped job or a 401.@claude.@claudefrom a write-access user still works, and that a PR from someone with no merged commits is still skipped.Not covered by automated tests — this is CI plumbing that can only be exercised by the real events on the base branch.
Changelog notes
No user-facing changes.
PR Backports
Checklist
And the last but not least:
check them.
Device testing does not apply: this changes only a GitHub Actions workflow and the
Zizmor audit config, neither of which is part of any image. The triggers themselves
can only be validated after merge, as described above. Documentation lives inline in
the workflow and in
.github/zizmor.yml.