GitHub Actions "could not find expected ':'" YAML error in CI
YAML scanned what it took to be a mapping key but never found the : that ends it, usually because a previous value spilled onto the next line or a multi-word key was left unquoted.
What this error means
The run fails with "Invalid workflow file" and a parser message "could not find expected ':'" with a line and column near the broken key.
GitHub Actions
Invalid workflow file: .github/workflows/ci.yml
(Line: 9, Col: 7): while scanning a simple key
could not find expected ':'Common causes
A value wrapped onto the next line without folding
A long unquoted value continues on the following line, so the scanner reads the continuation as part of a key and never finds its colon.
A key with spaces left unquoted
A bare multi-word key confuses the scanner about where the key ends and the colon should appear.
How to fix it
Quote or fold the long value
- Locate the line the parser names.
- Quote the value, or use a block scalar (
|or>) for multi-line content. - Re-run to confirm the parse succeeds.
.github/workflows/ci.yml
run: |
echo "first line"
echo "second line"Quote multi-word keys
Wrap any key that contains spaces or special characters in quotes so its boundary is unambiguous.
How to prevent it
- Use block scalars
|/>for multi-linerunblocks. - Quote keys and values that contain spaces or punctuation.
- Run a YAML linter as a pre-commit hook.
Related guides
GitHub Actions "mapping values are not allowed in this context" in CIFix GitHub Actions "while scanning ... mapping values are not allowed in this context" in CI - a stray colon…
GitHub Actions "found character '\t' that cannot start any token" in CIFix GitHub Actions "found character '\t' that cannot start any token" in CI - a tab was used for indentation,…
GitHub Actions "Required property is missing: jobs" in CIFix GitHub Actions "Required property is missing: jobs" in CI - the workflow has no top-level `jobs` mapping,…