YAML "mapping values are not allowed in this context" in CI
The YAML parser hit a : (colon plus space) in a position where a mapping cannot start, usually because a scalar value contains an unquoted colon. It reports "mapping values are not allowed in this context" at that column.
What this error means
Any YAML consumer (kubectl, a schema validator, a CI config loader) fails with "mapping values are not allowed in this context" and a line:column pointing at a colon inside a value.
error converting YAML to JSON: yaml: line 6: mapping values are not allowed in this contextCommon causes
An unquoted colon inside a scalar value
A value like message: build failed: retry has a second : the parser reads as a nested key, which is illegal here.
A misaligned key that lands mid-value
A key indented into the middle of a previous value creates a colon where the parser expected plain text.
How to fix it
Quote values that contain a colon
- Go to the reported line and find the second
:in the value. - Wrap the whole value in single or double quotes.
- Re-parse the file to confirm the error clears.
# wrong
message: build failed: retrying now
# right
message: "build failed: retrying now"Fix the indentation of a stray key
If a key drifted into a value, re-indent it to the correct level so it is a sibling, not embedded text.
How to prevent it
- Always quote scalars that contain
:(colon space). - Lint YAML with yamllint before it reaches CI.
- Use block scalars for multi-line messages that include colons.