Common causes
1. The editor inserted a tab when you pressed Tab
Editors configured for Makefiles or Go insert real tab characters. Replace them with spaces (two per level is the common convention) and set the editor to indent YAML with spaces.
server:
port: 8080server:
port: 80802. Mixed tabs and spaces that look aligned
A file edited by several people can contain lines indented with spaces next to lines indented with a tab. They line up on screen, but only the space-indented ones are valid.
database:
host: db.internal
port: 5432database:
host: db.internal
port: 54323. Content pasted from a tab-separated source
Copying from a spreadsheet, a TSV file or terminal output brings tabs along. Inside a quoted string or a block scalar a tab is just text, but at the start of a line it is indentation.
labels:
team: platform
tier: backendlabels:
team: platform
tier: backendFrequently asked questions
Are tabs allowed anywhere in YAML?
Yes, inside quoted strings, inside block scalars (| and >) and, in YAML 1.2, as separation between tokens on a line. They are only forbidden as indentation.
How do I find tabs in a YAML file?
Turn on “render whitespace” in your editor, or search with the regex ^\t. In VS Code, “Convert Indentation to Spaces” in the command palette fixes the whole file at once.
Can I stop this from happening again?
Add an .editorconfig with indent_style = space for *.yml and *.yaml files, and run a YAML linter such as yamllint in CI.