Common YAML indentation errors
YAML uses indentation to express structure, which means most parse failures are indentation mistakes wearing a different error message. A handful of patterns account for the majority of them.
A tab character used for indentation
YAML’s spec forbids tabs for indentation entirely. Most editors show tabs and spaces identically, so this is often invisible until the parser rejects it. Configure your editor to insert spaces on Tab, and check “show whitespace” if a document that looks fine still fails to parse.
Inconsistent indentation within a block
Every key at the same logical level needs the exact same indentation — not merely “more indented than its parent.” Two spaces here and three there, even if both look plausible, either produces a parse error or, worse, silently attaches a value to the wrong parent instead of failing loudly.
List items indented under the wrong key
A sequence item (- item) is conventionally indented at the same level as its parent key or one level deeper, depending on style — but it must be consistent within that list. Mixing the two within one sequence is a common source of “why is this key missing” bugs where an item silently attaches to the wrong parent instead of erroring.
An unintended multi-document stream
A stray ---line starts a new YAML document within the same stream. If a tool expects exactly one document and receives two, that’s a common and confusing failure mode — the file looks like one coherent document by eye, but a strict parser sees two.
Catching it before it ships
The YAML Formatter and Validator parses strictly and rejects multi-document input, tabs, and inconsistent indentation with a specific error rather than silently reinterpreting the structure — useful for catching these before a manifest reaches kubectl apply.