-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Description:
When parsing a YAML document that contains multiple merge anchors (<<: *anchor) in the same mapping — even if they reference different anchors — the ConvertFrom-Yaml command throws an error:
ConvertFrom-Yaml : Duplicate key <<
This occurs even though the YAML is syntactically valid and the merge keys are intended to apply multiple anchor expansions in sequence (as allowed by the YAML spec).
Example to Reproduce:
$actual = ConvertFrom-Yaml @'
dict:
test: &anchor2
key5: value
key6: test value
entry1: &anchor
key1: value 1
key2: value 2
entry2:
<<: *anchor
key2: other value
key3: final value
entry3:
key2: other value
key3: final value
<<: *anchor
<<: *anchor2
'@ -Schema Yaml11
Expected Behavior:
The command should successfully parse the YAML, merging the content from both *anchor and *anchor2 into entry3. The resulting structure should include all keys from both anchors, with later keys overriding earlier ones if there are conflicts (per YAML merge key semantics).
Notes:
The YAML specification allows multiple << keys in a single mapping (though it's rare), and some YAML parsers handle this by merging each anchor in order.
Even if the behavior should be modified (e.g., to warn or merge sequentially), the current implementation should not fail outright unless explicitly designed to reject such constructs.
At minimum, the error message should be more descriptive if multiple merge keys are intentionally disallowed.