fix: grant write permissions to claude-code-review workflow#467
Merged
fix: grant write permissions to claude-code-review workflow#467
Conversation
…ode-review workflow Co-authored-by: kimocoder <4252297+kimocoder@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix workflow permissions for code review action
fix: grant write permissions to claude-code-review workflow
Mar 19, 2026
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub Actions permissions for the Claude Code Review workflow so it can successfully exchange its OIDC token and post review comments (fixing the 401 Unauthorized failure during token exchange).
Changes:
- Change
pull-requestspermission fromreadtowrite. - Change
issuespermission fromreadtowrite.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
The Claude Code Review workflow was failing with
401 Unauthorizedduring OIDC token exchange becausepull-requestsandissueswere set toread— insufficient for posting review comments.Change
Original prompt
Problem
The Claude Code Review workflow (
.github/workflows/claude-code-review.yml) is failing with:See failing run: https://github.com/kimocoder/wifite2/actions/runs/23277044472
Root Cause
The workflow's permissions block has
pull-requests: readandissues: read, but the action needs write access to post review comments on PRs. The OIDC token exchange fails because the workflow identity only has read access.Current permissions:
Fix Required
In
.github/workflows/claude-code-review.yml, change the permissions block to:This is the only change needed. Do not modify any other part of the workflow file.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: How to properly fix the Claude workflow?
Assistant:
Let me investigate the failing workflow run and the repository's workflow configuration to understand the issue.
Assistant: Now I have a clear picture of the problem. Let me look more closely at the failing workflow file and understand the specific issue.
Diagnosis: Why Your Claude Code Review Workflow Is Failing
The failing run (#23277044472) is from the
claude-code-review.ymlworkflow, and the error is:This happens during the OIDC token → App token exchange step. The root cause is a permissions mismatch in your workflow file.
The Problem
Here's your current
claude-code-review.ymlpermissions block:The workflow uses
claude_code_oauth_tokenwith OIDC (id-token: write) to exchange for an app token that can post review comments. However, thepull-requestsandissuespermissions are set toread, so when the action tries to exchange the OIDC token for an app token with write capabilities, it fails because the workflow'sGITHUB_TOKEN(and the OIDC identity it represents) only has read access.The Fix
You need to grant write permissions for
pull-requestsandissuesso that the action can actually post review comments. Here's the corrected workflow:Key changes:
pull-requestsreadwriteissuesreadwriteAdditional Checks
Ensure the Claude Code GitHub App is installed on your repository with write access. Go to Settings → GitHub Apps (or Integrations) on your repo and verify the Anthropic/Claude app has the correct repository permissions (read & write for Pull Requests, Issues, and Contents).
Verify the
CLAUDE_CODE_OAUTH_TOKENsecret exists — go to Settings → Secrets and variables → Actions and confirm it's set.You also have a second workflow (
claude.yml) that usesanthropic_api_keyinstead of OIDC. That's a different auth method and shouldn't conflict, but be aware you have two Claude workflows that could both trigger onpull_requestevents. You may want to consolidate them or disable one to avoid duplicate reviews.Would you like me to create a PR with this fix appli...
This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.