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 error from the errors that follow it. Those skills come from the earlier chapters. Here you learn to sort a failure into a category by its signature, because the category tells you where to look for the fix.
Why categorize
A red check mark says only that something went wrong. The log text says what. Most failures fall into six categories, and each has recognizable wording and a typical exit code. Matching the first real error against these signatures is faster than reading the whole log.
The six categories are:
- Workflow syntax
- Environment
- Dependency
- Permission
- Secret
- Test
Workflow syntax
Signature: No job starts. The run shows "Invalid workflow file" or "This run likely failed because of a workflow file issue". An error annotation names the file and line. There is no step log, because no runner was ever assigned.
Typical causes are bad indentation, an unknown key, a misspelled runs-on, or an expression that refers to something that does not exist. A later chapter covers these in detail. For classification, remember one rule: if you cannot find a failing step, the problem is probably in the workflow file itself.
Environment
Signature: A command or file is missing, or a tool has the wrong version. The runner is a fresh virtual machine, so anything you did not install or check out is absent.
Common messages:
bash: line 1: pytest: command not found
Error: Process completed with exit code 127.npm error code ENOENT
npm error path /home/runner/work/demo/demo/package.json
npm error errno -2
npm error enoent Could not read package.jsonExit code 127 means the shell could not find the command. The ENOENT error means a file was not at the path the command expected. This is the failure in the baseline workflow from the topic's first example. package.json lives in app/, but npm ci runs in the repository root.
Other environment causes include:
- Using
ubuntu-latestwhen the project needs a specific OS or tool version. - Forgetting
actions/checkout, so the workspace is empty. - A step that wrote a file in one job and expects it in another. Each job gets a clean machine.
The fix for the subdirectory case is to set the working directory for run steps and point the cache at the right lock file:
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 affects only run steps. It does not change uses steps, which is why cache-dependency-path needs its own path.
Dependency
Signature: The install step fails before your code runs. The log shows a package manager error, not a shell error.
| Message | Likely meaning |
|---|---|
| `npm ci` can only install with an existing package-lock.json, or the lock file and `package.json` are out of sync | The lock file was not committed or was not updated after editing `package.json` |
| `ERESOLVE unable to resolve dependency tree` | Conflicting peer dependency versions |
| `404 Not Found - GET https://registry.npmjs.org/...` | Misspelled package name, a private package without credentials, or a removed version |
| `ETIMEDOUT`, `ECONNRESET`, HTTP 5xx | Network or registry trouble, often temporary |
| `EINTEGRITY` | The downloaded file does not match the checksum in the lock file |
The key question is whether the failure is deterministic. A lock file mismatch fails every time until you fix it. A timeout may pass on a re-run. If the same install passes on your machine, compare the versions of Node and npm. Also check whether your local node_modules hides a missing entry in the lock file.
Bad cache contents can also cause a dependency failure that looks like a code problem. If the error mentions a corrupt or missing module that is clearly listed in the lock file, try clearing the cache or changing the cache key.
Permission
Two different problems both read "permission denied". Separate them by the wording.
File mode. The shell refuses to execute a file:
bash: ./scripts/build.sh: Permission denied
Error: Process completed with exit code 126.Exit code 126 means the file exists but cannot be executed. The fix is to mark it executable in Git with git update-index --chmod=+x scripts/build.sh, or to run it as bash scripts/build.sh.
Token permissions. A call to the GitHub API is refused:
HttpError: Resource not accessible by integration
gh: Resource not accessible by integration (HTTP 403)The automatic GITHUB_TOKEN has only the access that the workflow's permissions allow. A job that comments on a pull request needs pull-requests: write:
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 }}Note that once you add a permissions block, every permission you do not list is set to none. If checkout then fails, add contents: read.
A third variant is Permission denied (publickey) from Git over SSH. That means the runner has no deploy key or SSH credentials.
Secret
Signature: A credential that should exist is empty. Secrets that are missing do not cause an error by themselves. The expression ${{ secrets.NAME }} evaluates to an empty string, so the failure appears in the step that uses it.
Typical messages:
Error: Input required and not supplied: token
npm error code E401
npm error Unable to authenticate, need: BearerCommon causes:
- The secret name is misspelled. Names are case-insensitive, but a different word is a different secret.
- The secret is defined in another repository, or in an environment that the job does not reference.
- The run was triggered by a pull request from a fork. GitHub does not pass repository secrets to those runs.
- Dependabot-triggered runs use a separate secret store.
Log lines containing a secret's value show *** in place of the value. If you see *** where you expected text, masking is working. It does not mean the secret is the problem. You should never print a secret to prove it is set. Check for emptiness with a test that reveals nothing:
steps:
- name: Check that the token is set
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
run: |
if [ -z "$API_TOKEN" ]; then
echo "::error::API_TOKEN is empty or not available to this run"
exit 1
fiTest
Signature: The environment and install are fine, and your test runner reports failing tests. The step exits with code 1, usually after printing assertion output and a summary.
FAIL src/sum.test.js
✕ adds two numbers (4 ms)
Expected: 5
Received: 4
Tests: 1 failed, 1 total
Error: Process completed with exit code 1.A test failure is a genuine result, not a setup problem. Work out whether it is a real bug, a flaky test, or a difference between your machine and the runner. Signs of a difference between environments include:
- Time zone and locale.
- Case-sensitive file paths. Linux runners are case-sensitive, while macOS and Windows machines usually are not.
- Line endings.
- Tests that depend on an installed service, such as a database.
- Slower runners, which turn timing assumptions into timeouts.
A test that fails once and passes on re-run is flaky. Re-running hides the problem. It does not fix it.
Signatures at a glance
| Category | Where it appears | Typical exit code | Deterministic? |
|---|---|---|---|
| Workflow syntax | Run header, no step log | None (no job runs) | Yes |
| Environment | Setup or first command step | 127, or 1 with `ENOENT` | Yes |
| Dependency | Install step | 1 | Mostly, except network errors |
| Permission | A step that calls an API or executes a file | 126, or 1 with 403 | Yes |
| Secret | A step that uses the credential | 1 | Yes, until the secret is set |
| Test | The test step | 1 | Usually, unless flaky |
Edge cases
- Two categories at once. A missing secret can look like a permission error, because both give 401 or 403 responses. Check whether the value is empty before you change permissions.
- Symptom in a later step. An environment problem in an early step can surface later, for example when
continue-on-errorhides it. Always go back to the first real error. - Timeouts and cancellations. A step stopped by
timeout-minutes, or a job cancelled by a concurrency rule, is not a code failure. The log says the operation was canceled, not that a command returned an error. - Out of resources. Exit code 137 often means the process was killed for running out of memory.
Exercise
A job fails at the step ./deploy.sh with bash: ./deploy.sh: Permission denied and exit code 126. A teammate suggests adding contents: write to the workflow's permissions block. Which category is this failure, and what is the correct fix?
Show answer
It is a permission failure of the file-mode kind, not a token problem. Exit code 126 means the file exists but is not executable. The permissions block controls the GITHUB_TOKEN, so changing it will not help. Make the script executable in Git with git update-index --chmod=+x deploy.sh and commit it, or call it as bash deploy.sh.
Exercise
A job's npm ci step prints Could not read package.json with code ENOENT, and the later npm test step is skipped. The repository keeps its Node project in app/. Which category is this, and which two settings in the workflow fix it?
Show answer
It is an environment failure, because the command ran in the wrong directory. Set defaults.run.working-directory: app so run steps execute in app/. Set cache-dependency-path: app/package-lock.json on actions/setup-node so the cache finds the lock file.