Sub topic 15
Troubleshooting failed runs
This chapter assumes you can read a workflow file and have written a deploy job like the one in the previous chapters. It covers how to find the cause of a failed run and fixes for the errors you are most likely to see.
Read the run from the top down
A failed run shows a red mark on the job and on the step that failed. Open the run, select the failed job, and expand the failing step. The last lines of that step usually name the error. Read upward from there, because the first error often causes the later ones.
The other signals to check:
- The Annotations panel on the run summary lists errors and warnings.
- A job marked skipped did not fail. Its
needsjob failed or itsifcondition was false. - A job that waits forever may be waiting for an environment approval.
Common errors and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Workflow does not start | Trigger or branch filter does not match, or the YAML is invalid | Check `on:` and the branch name. Look for a syntax error on the Actions tab. |
| `Unable to get ACTIONS_ID_TOKEN_REQUEST_URL` | The job lacks `id-token: write` | Add the permission to the deploy job. |
| `Not authorized to perform sts:AssumeRoleWithWebIdentity` | The role trust policy does not match the repository, branch, or environment | Update the `sub` condition in the trust policy. |
| `Artifact not found` | Different `name` in upload and download, or the jobs are not linked | Match the names and add `needs: build`. |
| Secret is empty | The secret is stored in another environment, or the run comes from a fork | Move it to the right scope. Secrets are not passed to fork pull requests. |
| `Resource not accessible by integration` | `GITHUB_TOKEN` has too few permissions | Add only the scope the step needs. |
| Job queued for a long time | A waiting approval, or a busy concurrency group | Approve the run, or wait for the earlier deployment. |
Check the subject claim for OIDC
The most common OIDC failure is a mismatch between the token's sub claim and the role's trust policy. When a job uses environment: production, the claim looks like repo:OWNER/REPO:environment:production. It does not contain the branch. A trust policy written for ref:refs/heads/main will reject that job.
Turn on more detail
Re-run the failed job with debug logging from the Re-run jobs menu and tick Enable debug logging. You can also set the repository variable ACTIONS_STEP_DEBUG to true. Remove it afterward, because debug logs are long and may show more than you want.
To inspect values inside a workflow, print non-secret context safely:
steps:
- name: Show context
run: |
echo "ref: $GITHUB_REF"
echo "event: $GITHUB_EVENT_NAME"
echo "actor: $GITHUB_ACTOR"Never print secrets. GitHub masks exact secret values in logs, but a transformed value, such as a base64 copy, is not masked.
Reproduce the failing command
If a build or deploy command fails, run the same command locally with the same versions. A mismatch in Node version, a missing lockfile, or a file whose name differs only in letter case is common. Linux runners treat Dist and dist as different paths, while macOS and Windows often do not.
Cases that are not errors
- A deployment that "succeeds" but shows old content may have synced the wrong directory. Check the path passed to
aws s3 sync. - A cancelled run may have been replaced by a newer one in a group with
cancel-in-progress: true. Your deploy group usesfalse, so runs queue instead.
Exercise
A deploy job fails at the credentials step with "Not authorized to perform sts:AssumeRoleWithWebIdentity". The job uses environment: production and the trust policy only allows repo:acme/shop:ref:refs/heads/main. What is wrong, and how do you fix it?
Show answer
With an environment set, the token's sub claim is repo:acme/shop:environment:production, so the branch-based condition does not match. Change the trust policy to allow that environment subject (or allow both subjects).