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| Filename | norway-problem.yaml |
| Format | YAML |
| Size | 161 bytes (161 bytes) |
| MIME type | application/yaml |
| SHA-256 | 17ba9fa29d8d1969a11d0f7ca1bce8c25a8421d2b0397b5ecc68616fe033332b |
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