Inconsistent Key Resolution in YAML 1.2 Merge Key (<<) Implementations
0 reputation · 29 Feb 2024, 00:56 UTC
The YAML 1.2 specification allows the merge key << to inherit key-value pairs from one or more source mappings. While the specification ensures that keys explicitly defined in the target mapping override any merged values, it does not provide a definitive rule for precedence when multiple merge sources contain the same key.
This ambiguity creates uncertainty when utilizing a list of merge sources. Different parser implementations, such as SnakeYAML and js-yaml, may resolve duplicate keys across multiple sources using different precedence logic (e.g., first-source vs. last-source precedence).
Additionally, the behavior of nested merge resolution—where a source mapping itself contains a merge key—is not uniformly standardized across libraries.
- Which source takes precedence when multiple mappings in a merge list contain the same key?
- Is there a standardized order for resolving nested merge keys before they are applied to the target mapping?