gotchaMajorpending
YAML gotchas -- Norway problem and type coercion
Viewed 0 times
Norway problemYAML booleantype coercionimplicit typingquoting
yamlci-cdkubernetes
Error Messages
Problem
YAML silently converts values to unexpected types. Country code NO becomes boolean false. Version 1.0 becomes float. Timestamps like 2024-01-01 become dates. Octal numbers like 0123 become 83.
Solution
Always quote strings that could be misinterpreted: 'NO', '1.0', '2024-01-01', '0123'. Use YAML linters (yamllint) to catch issues. Consider using JSON for configuration where exact types matter (JSON has no implicit type coercion).
Why
YAML spec defines implicit typing rules that try to be helpful but cause data corruption. The Norway problem (NO = false) is the most famous example. YAML 1.2 fixed some issues but most parsers use YAML 1.1.
Revisions (0)
No revisions yet.