Sub topic 6
Common failure categories and their signatures
This chapter assumes you can open a failed run, find the failing step, and tell the first real error from the errors that follow it. Once you have that error line, the next step is to sort it into a category. Each category has a typical signature in the log and a typical fix.
Why categorize
Sorting a failure into a category narrows where to look. A syntax error means the workflow file is wrong. A "command not found" error means the runner lacks a tool. Matching the message to a category tells you which file or setting to change first.
The six categories
| Category | Typical signature in the log | Usual cause |
|---|---|---|
| Workflow syntax | No steps ran. An error banner such as "Invalid workflow file" and a line number | Bad indentation, unknown key, wrong `uses` value |
| Environment | `command not found`, `No such file or directory`, wrong tool version | Missing tool on the runner, wrong working directory, wrong OS |
| Dependency | `npm ERR!`, `Could not resolve`, lock file out of sync | Changed or unavailable package, missing lock file |
| Permission | `403`, `Resource not accessible by integration`, `permission denied` | Missing `permissions:` entry, or a file without the execute bit |
| Secret | Empty value, `401`, `Bad credentials` | Secret not defined, misspelled, or unavailable to the event |
| Test | Assertion output, test runner summary, exit code 1 | A real code or test failure |
Signatures in practice
Environment: wrong directory
Take the baseline workflow from earlier in this tutorial. If package.json lives in app/, npm ci fails. The log shows an error like this:
npm ERR! code ENOENT
npm ERR! path /home/runner/work/repo/repo/package.json
npm ERR! enoent Could not read package.jsonThis looks like a dependency problem because it starts with npm. The path shows otherwise. The command ran in the repository root, where there is no package.json. The category is environment, and the fix is to set the working directory:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: app/package-lock.json
- run: npm ci
- run: npm testdefaults.run.working-directory applies only to run steps. Actions such as setup-node ignore it, which is why the cache path is given explicitly.
Permission: a 403 from the token
A job that comments on a pull request may fail with a 403. The GITHUB_TOKEN has only the access the workflow grants it, so add what the job needs:
permissions:
contents: read
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
steps:
- run: gh pr comment "$PR_NUMBER" --body "Checks finished"
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}Secret: an empty value
A missing secret does not cause an error by itself. The expression ${{ secrets.API_KEY }} evaluates to an empty string. The failure appears later, as a 401 or a message about a missing credential. Check the name, the scope (repository, environment, or organization), and the event that triggered the run.
Common errors when classifying
- Judging by the last error instead of the first. Later steps often fail because of the first one.
- Treating a test failure as a workflow problem. If the same test fails locally, fix the code.
- Calling every
npmerror a dependency failure. Read the path and the message first.
Exercise
A run shows Error: Resource not accessible by integration when a step tries to add a label to a pull request. Which category is this, and what do you change?
Show answer
Permission. The GITHUB_TOKEN lacks write access. Add a permissions block for the needed scope, for example pull-requests: write (or issues: write for labels on issues), then re-run.
Exercise
npm ci fails with "Could not read package.json", but the file exists in app/. Which category is this, and which setting fixes it?
Show answer
Environment. The command runs in the repository root. Set defaults.run.working-directory: app, or set working-directory: app on the step.