Test files › Structured data › norway-problem.yaml

YAML Norway problem test file

YAML 1.1 implicit-typing traps: unquoted NO becomes false, unquoted YES becomes true, version strings become floats, and leading-zero values parse as octal.

↓ Download norway-problem.yaml
Filenamenorway-problem.yaml
FormatYAML
Size161 bytes (161 bytes)
MIME typeapplication/yaml
SHA-25617ba9fa29d8d1969a11d0f7ca1bce8c25a8421d2b0397b5ecc68616fe033332b
What this file catchesThe famous "Norway problem" - a country list where NO silently becomes boolean false. Also catches version: 1.10 collapsing to 1.1. Parsers on YAML 1.2 core schema behave differently, so this file also reveals which spec version your library actually implements.

Handle it in code

Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.

Python

Python has no YAML parser in its standard library, so this is a line check, not a parser. It flags tab indentation, which YAML forbids, and the plain values that PyYAML and other YAML 1.1 loaders silently convert: NO becomes false, 0755 becomes 493, 1.10 becomes 1.1. Quote them.

import re

BOOLS = {"yes", "Yes", "YES", "no", "No", "NO", "on", "On", "ON", "off", "Off", "OFF",
         "true", "True", "TRUE", "false", "False", "FALSE"}

with open("norway-problem.yaml", encoding="utf-8") as f:
    for n, line in enumerate(f, 1):
        if re.match(r" *\t", line):
            print(f"line {n}: tab in the indentation, which YAML forbids")
            continue
        m = re.match(r"\s*(?:-\s+|[\w.-]+:\s+)([^\s\"'#][^#]*?)\s*$", line)
        value = m.group(1) if m else ""
        if value in BOOLS:
            print(f"line {n}: {value} is read as a boolean")
        elif re.fullmatch(r"0[0-7]+", value):
            print(f"line {n}: {value} is read as an octal number")
        elif re.fullmatch(r"\d+\.\d*0", value):
            print(f"line {n}: {value} is read as a float and loses its trailing zero")
        elif re.fullmatch(r"\d+(?::[0-5]?\d)+", value):
            print(f"line {n}: {value} is read as a base-60 number")

Run against this file, it prints: line 2: NO is read as a boolean line 5: ON is read as a boolean line 6: OFF is read as a boolean line 7: YES is read as a boolean line 8: 1.10 is read as a float and loses its trailing zero line 9: 0755 is read as an octal number line 10: 12:30:00 is read as a base-60 number line 11: yes is read as a boolean line 12: no is read as a boolean

Related guides and tools

Sample YAML fileCharacter encodingsVerify its SHA-256

Download & verify

curl -fsSL -o "norway-problem.yaml" "https://files.hexaqa.com/yaml/norway-problem.yaml"
curl -fsSL "https://files.hexaqa.com/yaml/norway-problem.yaml" | sha256sum # expect: 17ba9fa29d8d1969a11d0f7ca1bce8c25a8421d2b0397b5ecc68616fe033332b

More structured data test files

billion-laughs.xmlunclosed-tag.xmlvalid.xmlxxe-file-disclosure.xmltabs-invalid.yaml1000-rows.csv1million-rows.csvbom-and-semicolons.csv

← All Structured data files