Sub topic 9
Reading permission errors
This chapter assumes you can read a workflow file and know the permissions key from earlier chapters. Here you will learn to turn a failed run into the exact permission it needs.
What the error means
When a step calls the GitHub API with a token that lacks the right scope, GitHub rejects the request. The most common message is:
Resource not accessible by integration"Integration" here means the GITHUB_TOKEN, which GitHub issues on behalf of the Actions app. The message says the token's permissions do not cover the request. It does not say which permission is missing, so you must work that out.
You may also see an HTTP status such as 403 or 404. A 403 usually means the token is known but not allowed. A 404 can appear for private resources the token cannot see, so a "not found" error can also be a permission problem.
Find the failing step
- Open the failed run and find the first red step.
- Read the lines just above the error. They often show the API call, such as a request to create a comment or push a tag.
- Note which action or command made the call.
Then check the token's actual permissions. The job log has a "Set up job" section. Expand it and look at the "GITHUB_TOKEN Permissions" list. It shows what the job really received, after defaults and your permissions blocks are applied.
Map the call to a scope
Match the operation to a scope. Use this table as a starting point.
| Operation that failed | Permission to add |
|---|---|
| Comment on or label a pull request | `pull-requests: write` |
| Comment on or label an issue | `issues: write` |
| Push a commit, tag, or create a release | `contents: write` |
| Push an image to GitHub Container Registry | `packages: write` |
| Upload code scanning results | `security-events: write` |
| Request an OIDC token | `id-token: write` |
The action's documentation usually lists the permissions it needs. Check it before guessing.
A worked example
This job tries to label a pull request, but the workflow removed all permissions.
name: label
on: pull_request
permissions: {}
jobs:
label:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5The step fails with Resource not accessible by integration. Labeling a pull request needs pull-requests: write. The labeler also reads its config file, so it needs contents: read. Add both to the job only:
name: label
on: pull_request
permissions: {}
jobs:
label:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@v5Add one scope at a time and rerun. Stop when the job passes. This keeps the grant minimal.
When adding a scope does not help
Some failures are not fixed by a permission change:
- Fork pull requests. The token is read-only for pull requests from forks, whatever you declare. Writes will fail.
- Dependabot. Runs triggered by Dependabot get a read-only token by default.
- Reusable workflows. The caller sets the ceiling. A called workflow cannot gain more than the caller grants.
- Organization limits. An organization or enterprise policy can cap what a repository may grant.
Exercise
A job that publishes a release fails with "Resource not accessible by integration". The workflow sets permissions: contents: read. Which change fixes it with the least access, and where do you put it?
Show answer
Add contents: write to the publishing job's own permissions block, and keep contents: read at workflow level. Creating a release writes to repository contents, and putting the grant on the job keeps other jobs read-only.