GitHub Actions "mapping values are not allowed in this context"
By Kaveh Alemi·Latchkey
YAML found a colon where it expected a plain value, usually an unquoted string that itself contains a colon. The file fails to parse.
What this error means
The workflow is rejected with "mapping values are not allowed in this context", pointing at a line that has an unexpected colon.
github-actions
Invalid workflow file: .github/workflows/ci.yml#L13
mapping values are not allowed in this context
Common causes
An unquoted value containing a colon
A run command or string like time: 5 or a URL with a port (host:8080) is read as a key/value mapping unless quoted.
A duplicate or misplaced colon
Two colons on one line, or a colon after a value that should be a scalar, confuses the parser.
How to fix it
Quote values that contain colons
- Wrap any scalar containing a colon in single or double quotes.
- For multi-line commands use a block scalar with run: |.
.github/workflows/ci.yml
- run: echo "deploying to host:8080"
- name: 'fix: handle colon'
run: |
echo "ratio 2:1"
How to prevent it
- Quote any string with a colon, comma, or leading special character.
- Use block scalars (| or >) for multi-line shell snippets.
Frequently asked questions
What causes ""mapping values are not allowed in this context""?
A run command or string like time: 5 or a URL with a port (host:8080) is read as a key/value mapping unless quoted.
How do I fix "mapping values are not allowed in this context"?
Quote values that contain colons
Related guides
References