Python "yaml.scanner.ScannerError" in CI
PyYAML raises yaml.scanner.ScannerError when it cannot tokenize the document. The most common triggers are a literal tab used for indentation or an unquoted value containing a colon.
What this error means
A config-loading step fails with "yaml.scanner.ScannerError: while scanning ... mapping values are not allowed here" or "found character \t that cannot start any token".
yaml.scanner.ScannerError: mapping values are not allowed here
in "config.yml", line 7, column 14Common causes
Tabs used for indentation
YAML forbids tabs for indentation; a tab inserted by an editor breaks the scanner.
An unquoted value with a colon or special character
A bare value like url: http://x:8080 confuses the scanner; it must be quoted.
How to fix it
Fix indentation and quote ambiguous values
- Replace all tabs with spaces in the file.
- Quote any scalar that contains a colon, hash, or leading special character.
- Validate the file with a YAML linter in CI before the app reads it.
# wrong: tab indent + unquoted colon value
# fixed:
endpoint: "http://service:8080"
timeout: 30How to prevent it
- Configure editors to expand tabs to spaces for YAML.
- Run yamllint in CI before consuming config.
- Use safe_load and surround risky scalars with quotes.