Pyyaml: duplicate anchors throw ComposerError

Created on 25 Nov 2017  路  4Comments  路  Source: yaml/pyyaml

import yaml

foo = """
foo: &foo "foo"
bar:
    x: *foo
    y: &foo "bar"
    z: *foo
"""

bar = yaml.load(foo)
print(bar)

according to the yaml specification here http://yaml.org/spec/1.2/spec.html#anchor//

When composing a representation graph from serialized events, an alias node refers to the most recent node in the serialization having the specified anchor. Therefore, anchors need not be unique within a serialization. In addition, an anchor need not have an alias node referring to it. It is therefore possible to provide an anchor for all nodes in serialization.

this was fixed in older version of ruaml.yaml apparently as well before reintroducing the bug

Most helpful comment

not sure why this was closed, as it is indeed a bug

All 4 comments

not sure why this was closed, as it is indeed a bug

I too have encountered this problem while processing some gitlab ci yaml files. The files have duplicate anchors but are perfectly valid. When I modified a temporary local copy of the yaml files to remove the duplicates issue, the files processed fine.

Hmm, is there any workarounds?

Hmm, is there any workarounds?

Not that I know of, but there is a pending PR: #394

Was this page helpful?
0 / 5 - 0 ratings

Related issues

perrygeo picture perrygeo  路  8Comments

mikedlr picture mikedlr  路  7Comments

Jwomers picture Jwomers  路  10Comments

graingert picture graingert  路  7Comments

itamarst picture itamarst  路  3Comments