diff --git a/yamlpath/commands/yaml_set.py b/yamlpath/commands/yaml_set.py index 8ce57ae0..cfb67ad9 100644 --- a/yamlpath/commands/yaml_set.py +++ b/yamlpath/commands/yaml_set.py @@ -455,7 +455,7 @@ def _alias_nodes( if anchor_name: # Rename any pre-existing anchor or set an original anchor name - anchor_node.anchor.value = anchor_name + anchor_node.yaml_set_anchor(anchor_name, always_dump=True) elif anchor_node.anchor.value: # The source node already has an anchor name anchor_name = anchor_node.anchor.value