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

yaml.composer.ComposerError: found duplicate anchor [SOLVED] #571

Closed
YAMLcase opened this issue Jul 24, 2020 · 2 comments
Closed

yaml.composer.ComposerError: found duplicate anchor [SOLVED] #571

YAMLcase opened this issue Jul 24, 2020 · 2 comments

Comments

@YAMLcase
Copy link

YAMLcase commented Jul 24, 2020

(Dropping here in case someone else stumbles upon this)

attempting to use duplicate anchors feature will result in a yaml.composer.ComposerError: found duplicate anchor error. While this is a YAML 1.2 feature, pyyaml does not yet support parsing duplicate anchors.

override-anchor branch of yaml/pyyaml has a PR that supports the duplicate anchors parsing feature. This can be installed by simply installing the pip from git:

pip install --upgrade git+https://github.com/yaml/pyyaml.git@override-anchor

diff from master branch only contains the PR, so it should be save everywhere else.

References:

Debian Bug Report:
python-yaml: YAML loader complains about non-unique anchors
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=515634

pyyaml PR:
Support overriding anchors #394
yaml/pyyaml#394

pyyaml diff with master:
https://github.com/yaml/pyyaml/compare/override-anchor

@YAMLcase
Copy link
Author

FAQ: "why would you want to use duplicate anchors?"

In my use case, I'm utilizing stage includes. This requires a new field "id:" on the stage that I'd really like it to be the same as "name:" without having to repeat myself.

---
test_name: do_some_things
stages:
  - {id: ping_api_endpoint, type: ref}
  - {id: get_token, type: ref}
  - {id: do_something, type: ref}
  - {id: revoke_token, type: ref}


---
stages:
  - id: &id ping_api_endpoint
    name: *id
    ...

  - id: &id get_token
    name: *id
    ...

  - id: &id do_something
    name: *id
    ...

  - id: &id revoke_token
    name: *id
    ...

@michaelboulton
Copy link
Member

Will address this just by duplicating the id as the name if it's present

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