Skip to content
Latchkey

GitHub Actions "could not find expected ':'" YAML error in CI

YAML scanned what it took to be a mapping key but never found the : that ends it, usually because a previous value spilled onto the next line or a multi-word key was left unquoted.

What this error means

The run fails with "Invalid workflow file" and a parser message "could not find expected ':'" with a line and column near the broken key.

GitHub Actions
Invalid workflow file: .github/workflows/ci.yml
(Line: 9, Col: 7): while scanning a simple key
could not find expected ':'

Common causes

A value wrapped onto the next line without folding

A long unquoted value continues on the following line, so the scanner reads the continuation as part of a key and never finds its colon.

A key with spaces left unquoted

A bare multi-word key confuses the scanner about where the key ends and the colon should appear.

How to fix it

Quote or fold the long value

  1. Locate the line the parser names.
  2. Quote the value, or use a block scalar (| or >) for multi-line content.
  3. Re-run to confirm the parse succeeds.
.github/workflows/ci.yml
run: |
  echo "first line"
  echo "second line"

Quote multi-word keys

Wrap any key that contains spaces or special characters in quotes so its boundary is unambiguous.

How to prevent it

  • Use block scalars |/> for multi-line run blocks.
  • Quote keys and values that contain spaces or punctuation.
  • Run a YAML linter as a pre-commit hook.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →