The Error
yaml.scanner.ScannerError: mapping values are not allowed here
in "config.yml", line 4, column 12
Or, from a different parser:
Error: (<unknown>): mapping values are not allowed in this context at line 2 column 15
Every variant says roughly the same thing: the YAML parser was reading along, expecting one kind of structure, and hit a colon (:) somewhere it didn't expect one. This shows up constantly in GitHub Actions workflows, docker-compose.yml, Kubernetes manifests, and Helm charts — anywhere YAML is used, which in modern DevOps is nearly everywhere.
There are three real causes behind almost every instance of this error.
Cause 1: An Unquoted Value Containing a Colon
This is the most common cause, and the GitHub Actions version of it is especially frequent:
steps:
- name: Build: production
run: npm run build
Why it fails: in YAML, a colon followed by a space (: ) means "this is the start of a key-value mapping." The parser reads name: Build: production and gets confused — is Build a new nested key under name? YAML syntax doesn't allow a mapping value to itself contain an unquoted colon-space sequence, because that's structurally ambiguous.
Fix: wrap the whole value in quotes:
steps:
- name: "Build: production"
run: npm run build
This applies to any value with a colon in it — a URL like http://example.com, a time like 14:30, a Windows path like C:\Users. When in doubt, quote it.
Cause 2: A Tab Character in the Indentation
services:
web:
image: nginx
That first line under services: might look correctly indented in your editor, but if it's a tab character rather than spaces, YAML rejects it outright.
Why it fails: this isn't a style guideline — it's a hard rule in the YAML specification. Tabs are forbidden for indentation, full stop. Not "discouraged," not "inconsistent with the rest of the file" — actually disallowed by the spec, and every compliant parser enforces it.
This is a very common copy-paste injury: you copy a snippet from a terminal, a PDF, or a chat message, and it carries an invisible tab character with it that looks identical to spaces in your editor.
Fix: configure your editor to insert spaces when you press Tab in .yml/.yaml files (in VS Code: "[yaml]": { "editor.insertSpaces": true } in settings), and if you suspect a pasted snippet, retype the indentation manually rather than trusting what was pasted.