YAML: The Norway Problem

Earlier this week, Haroen Viaene posted this tweet about YAML:

The linked-to page contains the documentation on what defines a boolean in YAML, and details that it can be parsed using this regex:



The reason to why this is problematic in some cases, is “The Norway Problem” YAML has: when you abbreviate Norway to its ISO 3116-1 ALPHA-2 form NO, YAML will return false when parsing it:

- GB
- IE
- FR
- DE
- NO
>>> from pyyaml import load
>>> load(the_configuration)
{'countries': ['GB', 'IE', 'FR', 'DE', False]}

👉 The solution is to either escape these values in double quotes, or to use a library — such as StrictYAML for Python — that won’t convert NO to False.


Other problematic values in YAML are version numbers that end in .0 and a lastname such as Null. By default these get converted to numbers or NULL respectively.

The Norway Problem →
StrictYAML →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.