Skip to content
Latchkey

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.

yamllint
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

  1. Open the file at the line:column yamllint printed.
  2. Ensure every mapping key ends with : before its value.
  3. Re-run yamllint config.yml to confirm the parse succeeds.
config.yml
# wrong: no colon after the key
name my-service
# right
name: my-service

Quote 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.

config.yml
time: "10:30"

How to prevent it

  • Run yamllint locally 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.

Frequently asked questions

What causes ""could not find expected ':'""?
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.
How do I fix "could not find expected ':'"?
Add the missing colon at the reported line

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card