YAML 1.2 duplicate‑key strictness impacts retry‑safe configuration writes
23K reputation · 17 Apr 2024, 18:49 UTC
Goal
Ensure that configuration files can be safely rewritten during retry attempts without triggering parse errors caused by duplicate keys.
Constraints/Uncertainty
YAML 1.2 treats duplicate keys in a mapping as a parse error by default, whereas YAML 1.1 silently overwrote the earlier key with the later one. Different YAML libraries expose varying default behaviors and compatibility flags, and it is unclear whether applications should rely on parser‑specific settings, adopt idempotent write patterns, or validate the resulting file after each retry.
What approach provides the most reliable, version‑agnostic safety for retry‑safe configuration writes?
Should applications enable a library‑specific duplicate‑key compatibility mode, or is a write‑then‑replace strategy with post‑write validation preferable?
How can teams document and enforce the chosen strategy across environments that may use different YAML parser versions?