Skip to content
Novus Examples
yaml1 KB

YAML Implicit Typing Traps

Twenty-two unquoted values whose type depends entirely on the resolver. The worst is the leading zero: 0755 is 493 under YAML 1.1 and 755 under YAML 1.2, so both resolvers return a number and they return different ones. Also covers base-60 times, a version that loses its trailing zero, an integer past IEEE-754 precision, dates, and .inf / .nan.

Preview — first 35 linesyaml
# Implicit typing. Nothing here is quoted, so every value is whatever the resolver decides it
# is — and the resolvers disagree. Each key names the trap it carries.
version_trailing_zero: 1.10
version_quoted: "1.10"

sexagesimal_time: 22:22
sexagesimal_duration: 1:30:00
time_quoted: "22:22"

# A leading zero is the nastiest of these, because BOTH resolvers return a number and they
# return DIFFERENT numbers: YAML 1.1 reads 0755 as octal (493), YAML 1.2's core schema reads
# it as plain decimal (755). Neither gives you back the text you wrote.
octal_yaml_1_1: 0755
octal_yaml_1_2: 0o755
leading_zero_identifier: 012345
# 9 is not an octal digit, so YAML 1.1 leaves this a string while YAML 1.2 makes it 900.
build_number_leading_zero: 0900
hexadecimal: 0x1F
binary_yaml_1_1: 0b1011

big_integer: 9007199254740993
float_precision: 0.1
exponent: 1e3
plus_signed: +42

date_only: 2026-01-15
date_time: 2026-01-15T09:30:00Z
date_quoted: "2026-01-15"

infinity: .inf
negative_infinity: -.inf
not_a_number: .nan

version_string_looks_numeric: 2.0

Specifications

Traps
22
Sexagesimal Values
2
Leading Zero Forms
4
Precision Loss Value
9007199254740992
Version Trailing Zero Loss
1.10 -> 1.1
Leading Zero Disagreement
0755 is 493 under YAML 1.1 and 755 under YAML 1.2 core

Testing contract

Expected to recover
Scenario
Round-trip unquoted YAML scalars whose type the resolver infers
Expected result
version_trailing_zero loads as the float 1.1 and dumps as "1.1", losing the original text, and octal_yaml_1_1 loads as 493 or 755 depending on the resolver version rather than staying "0755"

What is a .yaml file?

YAML (YAML Ain't Markup Language) is a human-readable data-serialization format using indentation, key-value pairs, and lists, and is a superset of JSON. It supports comments, anchors, and multiple documents per file, favoring readability for configuration. Its indentation sensitivity makes it error-prone to hand-edit.

How to use this file

Use an example YAML file to test config parsers, indentation and anchor handling, multi-document streams, and safe-loading to avoid arbitrary object construction.

How to use this file for testing

“YAML Implicit Typing Traps” is a deterministic Novus Examples fixture for Config parsing, Encoding detection, Editor testing. TOML and INI configuration files with nested sections and typed values — for testing config parsers and loaders.

Documented properties for this file: YAML · 1,048 bytes. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Pipeline and infrastructure fixtures are inert configuration: steps reference fictional images and scripts, and nothing here executes. Run your linter, schema validator, migrator, or policy engine against them, and expect the deprecated-syntax and intentionally invalid variants to be rejected.

Point your config loader at the file and assert it reads the documented sections and typed values, including any deliberately-tricky nesting or comments.

Code examples

import yaml  # pip install pyyaml

with open("implicit-typing.yaml") as f:
    data = yaml.safe_load(f)
print(data)

Generated by generation/pipelines.py. Free for any use, no attribution required — license.