[WIP] Fix GitHub Actions job failure in claude-code-review.yml#62
Merged
Conversation
Agent-Logs-Url: https://github.com/ziembor/gomailtesttool/sessions/9a3d5787-4b0a-4268-ba35-fdbe09e0f7b8 Co-authored-by: ziembor <1870879+ziembor@users.noreply.github.com>
Copilot stopped work on behalf of
ziembor due to an error
May 1, 2026 22:39
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.
if:guard toclaude-reviewjob in.github/workflows/claude-code-review.ymlto skip on fork PRsOriginal prompt
Create a PR that fixes the failing GitHub Actions job in run https://github.com/ziembor/gomailtesttool/actions/runs/25236018071/job/74002302380?pr=61.
Failure summary (from job logs): the
anthropics/claude-code-action@v1step fails during OIDC/app token exchange with401 Unauthorized - User does not have write access on this repository.Repository: ziembor/gomailtesttool
Workflow file:
.github/workflows/claude-code-review.ymlImplement a safe fix so the workflow does not fail on fork PRs / contexts without write permissions.
Requirements:
pull_request.if:guard so the job runs only when the PR head repo is the same as the base repo (i.e., not a fork):github.event.pull_request.head.repo.full_name == github.repository.Deliverables:
main.Reference: Use commit ref from the failing job logs:
14fabff4cd2858db36f44e5aa6a3cf7c9137ec6dfor any code links in discussion if needed.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The job is failing before it ever gets to reviewing code. It dies while trying to exchange the OIDC token for an “app token”:
401 Unauthorized - User does not have write access on this repositoryAction failed with error: User does not have write access on this repositoryThis is a permissions/token-scope issue, not a code/test failure in your repo.
Why it’s happening
Your workflow runs on
pull_requestand usesanthropics/claude-code-action@v1withid-token: write:The Claude action then attempts an authenticated operation that requires write access to the repo (or it requires a token that can perform write actions). On PRs—especially from forks—GitHub deliberately restricts token permissions, and OIDC/app-token exchanges commonly fail if the actor/token doesn’t have sufficient repo write rights.
Fix options (pick one)
Option A (recommended): Don’t run this workflow on untrusted PRs / forks
Gate the job so it only runs when the PR comes from the same repository (not a fork), and ideally when the author is trusted.
Add an
ifcondition to the job:If you also want to restrict to members/collaborators:
This avoids the “no write access” situation that occurs for fork PRs.
Option B: Switch to
pull_request_target(only if you understand the security implications)pull_request_targetruns in the context of the base repo (so tokens/permissions work), but it can be dangerous if you check out and execute untrusted PR code.If you do this, do not run arbitrary code from the PR. For a review bot that only comments/diffs, it can be acceptable.
Change:
to:
And keep checkout safe (checkout the base repo by default, or be very deliberate about what you fetch). If you need the PR diff, use
gh pr diff(as your prompt already suggests) rather than executing PR code.Option C: Ensure the Claude OAuth token is correct and has the required access
Your step uses:
If that secret is missing on fork PRs (common) or not authorized for this repo, the action may fall back to an OIDC/app-token path and then fail with the “no write access” error you see. Ensure:
CLAUDE_CODE_OAUTH_TOKENis set in repo secretsziembor/gomailtesttoolIn practice, Option A or B is usually still necessary because secrets won’t be exposed to fork PRs.
Minim...
This pull request was created from Copilot chat.