yamllint "syntax error: could not find expected ':'" in CI
yamllint runs the YAML parser first, and the parser reached a point where it needed a : to close a mapping key but found something else. The line and column in the message point at where the colon was expected.
What this error means
yamllint exits non-zero with "syntax error: could not find expected ':' (syntax)" and a line:column. The block scalar, list, or nested key just above is malformed.
config.yml
8:3 error syntax error: could not find expected ':' (syntax)Common causes
A key line is missing its colon
A line meant to be a mapping key (name value) has no :, so the parser cannot tell where the key ends and the value begins.
Broken indentation merges two lines into one node
An under-indented value or a wrapped long string makes the parser read a continuation where it expected a new key: pair.
How to fix it
Add the missing colon at the reported line
- Open the file at the line:column yamllint printed.
- Ensure every mapping key ends with
:before its value. - Re-run
yamllint config.ymlto confirm the parse succeeds.
# wrong: no colon after the key
name my-service
# right
name: my-serviceQuote values that contain colons
A value like time: 10:30 is ambiguous. Quote it so the inner colon is not read as a new mapping.
time: "10:30"How to prevent it
- Run
yamllintlocally or in a pre-commit hook before pushing. - Quote any scalar that contains a colon followed by a space.
- Keep two-space indentation consistent across the file.