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".
python
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.
config.yml
# 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.
Related guides
Python "json.decoder.JSONDecodeError: Expecting value" in CIFix "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" in CI - json.loads got an empty…
Python "configparser.NoSectionError" in CIFix "configparser.NoSectionError" in CI - configparser was asked for a section that the loaded .ini file does…
Python "argparse: error: unrecognized arguments" in CIFix "error: unrecognized arguments" from argparse in CI - the CLI was passed a flag the parser does not defin…