yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

Validate mapping key uniqueness

Open brondani opened this issue 2 years ago • 2 comments

According to YAML spec 1.2.2:

The content of a mapping node is an unordered set of key/value node pairs, with the restriction that each of the keys is unique.

The changes proposed here check the uniqueness of scalar mapping keys, throwing a NonUniqueMapKey exception when by inserting a new key/value pair an identical scalar key is already present in a mapping. Non identical but equivalent scalar content, for example “0o13” (octal) or “0xB” (hexadecimal), are not considered.

Address https://github.com/jbeder/yaml-cpp/issues/60.

brondani avatar Sep 01 '23 14:09 brondani

Would like to see this merged. It's a common source of problems to have duplicate keys in a map and have the content being overridden silently. We have huge config files with YAML and it's easy to miss an existing entry and duplicate it, causing issues due to the silent overriding.

apirogov avatar Jan 14 '25 11:01 apirogov

seconded...

matemat13 avatar Nov 25 '25 18:11 matemat13