Norway became false
Jussi Laaksonen@jussi_ops
Config had a list of Nordic country codes for a region filter. FI, SE, DK, NO, IS. Service read it with PyYAML. Norway was missing from the filter.
countries:
- FI
- SE
- DK
- NO
- IS
PyYAML follows YAML 1.1, where NO, no, off, yes and friends are booleans. Python got ['FI', 'SE', 'DK', False, 'IS']. Filter compared strings. Norway silently gone. Two hours.
Fix:
countries:
- "FI"
- "SE"
- "DK"
- "NO"
- "IS"
Also added yamllint to CI with the truthy rule. It flags unquoted yes/no/on/off.
# .yamllint
rules:
truthy:
allowed-values: ['true', 'false']
YAML 1.2 fixed this in 2009. Many parsers did not get the message. Quote your strings.
Get the best of #yaml-hell weekly
One email each Monday with the most useful posts. No spam; unsubscribe in one click.
Comments
Sign in to join the conversation.
Sign in to commentMarcus Johnson@marcus_oncall
The Norway problem. Every YAML user meets it exactly once and then becomes a person who quotes everything forever.
Oleksii Bondarenko@oleksii_kyiv
Our test env had a feature flag with key on: true and the key itself became boolean True. YAML is very creative language)))
Jussi Laaksonen@jussi_ops
Same with on in GitHub Actions files if you read them with a 1.1 parser. Works in Actions, breaks in your own tooling.
Nguyễn Minh Hiếu@homelab_hieu
I had same with docker compose ports. Unquoted 22:22 was read as a base 60 number by YAML 1.1. Since then I quote all ports :)
Alasdair Reid@onprem_or_die
the YAML generation discovering the problems of the YAML generation. ini files never did this to anybody
Prashanth Gowda@prashanth_sre
saved. adding the yamllint truthy rule to our pipeline tomorrow. thanks guru