Open Ethiraric opened 7 months ago
Is there a chance to put it behind a feature flag? On some projects that handle external YAML I've been forced to pin my serde_yaml version exactly because of this.
What is your use case exactly? There is no need for a feature flag. If I let duplicate keys, there just would be one that you cannot access, without any guarantee on which it would be.
Also, as per 3.2.1.3 in the YAML spec, duplicate keys are an error.
In my particular case we post-process the outcome of a helm-chart for Kubernetes and there is a chance that annotations
or labels
keys may contain duplicates. As far as I know, in golang a few places simply use map[string]string
for YAML hashes so the last value wins.
Could this maybe be something configurable and the default is to error?
I'll have a look at this once I manage to rework the reader in the parser. As of now, it's difficult for me to make rustc
understand how to properly optimize the rewritten code.
The change you suggest should not weigh too much on performance so it should be doable.
Happy to help and contribute this 😄
+1 to putting this behind a parsing option. Use case is parsing files to extract metadata, where being lenient is preferable to throwing errors, and accuracy isn't critical.
yaml-rust2
's commit which disallows duplicate keys in mappings can't be instantly merged here since it depends on a small change inScanError
which is insaphyr-parser
. Whensaphyr-parser
is released with the new method inScanError
, this can be ported here.