Closed stevenengler closed 2 years ago
Fixed in 0.9.4. I didn't realize this was specified as disallowed by the YAML spec.
Wow that was quick, thanks!
Except that the majority of YAML parsers out there allow duplicate keys, and take a "last key wins" philosophy. See e.g. https://github.com/chyh1990/yaml-rust/issues/19
I've got some things which were considered valid before but now aren't. I'd argue this was a breaking change, despite the YAML spec.
Being devils advocate, semver is based around documented behaviour. Since it's documented in the YAML spec as invalid behaviour, and since serde-yaml doesn't document otherwise, this is a valid bug fix.
Obligatory XKCD: obviously this is hyperbole, but no matter where you draw the line someone will find an issue with the change.
That being said, it did cause our codebase to break 😅
The YAML spec disallows duplicate keys:
When deserializing to a custom serde-derive struct we can use
#[serde(with = "serde_with::rust::maps_duplicate_key_is_error")]
to prevent duplicate keys. But if we want to deserialize to aserde_yaml::Value
, serde-yaml's mappings will ignore duplicate keys. Is there any way to achieve the same behaviour when deserializing to aserde_yaml::Value
?The reason for wanting to deserialize to a
serde_yaml::Value
is that I would like to take advantage of the newapply_merge()
feature. So what I'm doing is: