Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yq complains of duplicate anchors #66

Open
lousyd opened this issue Aug 27, 2019 · 2 comments
Open

yq complains of duplicate anchors #66

lousyd opened this issue Aug 27, 2019 · 2 comments

Comments

@lousyd
Copy link

lousyd commented Aug 27, 2019

I have a file like this:

$ cat test.yml 
app: testyaml
because: &because
  - testing
  - iswhy
reason: &because
why: *because

...and get this error when processing it with yq:

$ yq '.' test.yml 
yq: Error running jq: ComposerError: found duplicate anchor 'because'; first occurrence
  in "test.yml", line 2, column 10
second occurrence
  in "test.yml", line 5, column 9.

According to the YAML specs, duplicate anchors are valid:

3.2.2.2. Anchors and Aliases

[...] 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. [...]

7.1. Alias Nodes

[...] The alias refers to the most recent preceding node having the same anchor. [...]

@kislyuk
Copy link
Owner

kislyuk commented Aug 28, 2019

yq depends on PyYAML for YAML deserialization. This bug is therefore blocked by yaml/pyyaml#100 in PyYAML. Please file a comment or new issue in that reposotory.

Is there a specific use case that you have in mind?

@lousyd
Copy link
Author

lousyd commented Aug 29, 2019

Thank you for the reference. I don't have a representative use case, I don't think. I just came across the problem while trying to process gitlab ci yaml files. Some of the files have duplicate anchors. I modified a local copy of those files in order to workaround the problem for the time being.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants