Sub topic 8
When the workflow file itself is invalid
This chapter assumes you can read YAML and know the job, step, and runner structure from earlier chapters. Here the failure happens before any step runs, so there is no step log to read.
How an invalid file looks
GitHub parses the workflow file before it creates a run. If parsing or schema validation fails, you see one of these:
- A run marked as failed with no jobs. The run page shows an "Invalid workflow file" annotation that names the file and line, for example
.github/workflows/ci.yml#L8. - No run at all. The workflow never triggers, or it is missing from the Actions sidebar.
Both cases mean the problem is in the file or its location, not in your code or the runner.
Common causes
| Symptom | Likely cause |
|---|---|
| "error in your yaml syntax on line N" | Tab characters, bad indentation, an unquoted `:` in a value |
| "Unexpected value 'runs_on'" | Misspelled or unknown key |
| A job fails validation about `runs-on` | `runs-on` is missing from the job |
| "Unrecognized named-value" | A typo in an expression such as `${{ secret.TOKEN }}` instead of `secrets.TOKEN` |
| `needs` error | `needs` names a job that does not exist |
| Workflow never appears | File is not in `.github/workflows/`, or lacks a `.yml` or `.yaml` extension |
| Run never starts | `on:` filters (branches, paths) do not match the event |
The reported line is where the parser noticed the problem. The mistake is often on the line above, such as an unclosed quote or a wrong indent level.
A worked example
This file has two mistakes. Find them before reading on.
name: CI
on: [push, pull_request]
jobs:
test:
runs_on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm testFirst, runs_on should be runs-on. Second, the last - run is indented under the previous step, which makes it an invalid child of a step mapping. The fixed file is:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm testEvery step is a list item at the same indent level, and each item holds either uses or run.
Checking the file before you push
You can catch most of these errors locally. A YAML linter reports syntax errors with line numbers. For example:
python -c "import yaml,sys; yaml.safe_load(open('.github/workflows/ci.yml'))"This command passes if the YAML is well formed. It does not check the GitHub workflow schema, so a misspelled key like runs_on still passes. For schema checks, use an editor extension for GitHub Actions or a tool such as actionlint. Both catch unknown keys, bad needs references, and expression typos.
Triggers that never fire
A valid file can still produce nothing. Check these in order:
- The file is under
.github/workflows/on the branch you pushed. Forpull_request, GitHub uses the workflow file from the merge result, so confirm the file exists on the right branch. - The
on:block lists the event you triggered. - Any
branches,tags, orpathsfilters match your change.
Exercise
A push to main creates a run on the Actions tab. The run is red, shows no jobs, and the annotation says "You have an error in your yaml syntax on line 12". The step logs are empty. Where do you look, and why are there no logs?
Show answer
Open line 12 of the workflow file named in the annotation, and also check the line or two above it for bad indentation, tabs, or an unclosed quote. There are no logs because GitHub rejected the file while parsing it, so no job was scheduled and no step ever ran.
Exercise
Your YAML parses cleanly with a local linter, but GitHub reports "Unexpected value 'runs_on'". Why did the linter miss it, and what fixes it?
Show answer
The linter only checks that the YAML is well formed, and runs_on is a valid YAML key. GitHub validates against the workflow schema, where the key is runs-on. Rename the key to runs-on, and use a schema-aware tool such as actionlint to catch this locally.