yaml-merge ignores anchors=left when aliased hash merge keys are present
Closed this issue · 1 comments
wwkimball commented
Operating System
- Name/Distribution: ANY
- Version: ANY
Version of Python and packages in use at the time of the issue.
- Distribution: ANY supported
- Python Version: ANY supported
- Version of yamlpath installed: 3.6.4
- Version of ruamel.yaml installed: ANY supported
Minimum sample of YAML (or compatible) data necessary to trigger the issue
---
# lhs.yaml
aliases:
- &name_a a_name
- &name_b b_name
ref_hash: &ref_hash
*name_a : {}
*name_b : {}
imp_hash_a:
<<: *ref_hash
imp_hash_b:
<<: *ref_hash
---
# rhs.yaml
aliases:
- &name_a NEW_A_VALUE
- &name_b NEW_B_VALUE
Complete steps to reproduce the issue when triggered via:
- yaml-merge --anchors=left lhs.yaml rhs.yaml
Expected Outcome
---
# lhs.yaml
aliases:
- &name_a NEW_A_VALUE
- &name_b NEW_B_VALUE
ref_hash: &ref_hash
*name_a : {}
*name_b : {}
imp_hash_a:
<<: *ref_hash
imp_hash_b:
<<: *ref_hash
Actual Outcome
---
# lhs.yaml
aliases:
- &name_a a_name
- &name_b b_name
ref_hash:
*name_a : {}
*name_b : {}
imp_hash_a:
anchor01: &ref_hash
NEW_A_VALUE : {}
NEW_B_VALUE : {}
imp_hash_b:
<<: *anchor01
NEW_A_VALUE : {}
NEW_B_VALUE : {}
Note that the ref_hash anchor moves and gets redefined where the first reference formerly existed, then ignored for the second reference.
[This is from memory and the detail of the actual outcome may be slightly different from that hand-typed above. The point is, the merge causes a a redefinition of the original anchor and an "explosion" of its aliases.]