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 with anchors and aliases is broken #120

Closed
systemmonkey42 opened this issue Sep 4, 2021 · 6 comments · Fixed by #122
Closed

YAML with anchors and aliases is broken #120

systemmonkey42 opened this issue Sep 4, 2021 · 6 comments · Fixed by #122
Labels
bug Something isn't working

Comments

@systemmonkey42
Copy link

Description

Valid YAML file containing anchors and aliases/merge points is broken by yamlfix

Current behavior

Source yaml: This is a snippet from docker-compose.yml, trimmed to focus on the issue

x-node-volumes: &node-volumes
  node3_data:

x-vault-volumes: &vault-volumes
  vault_data:

x-mongo-volumes: &mongo-volumes
  mongo_data:

x-certmgr-volumes: &certmgr-volumes
  cert_data:

volumes:
  <<: *node-volumes
  <<: *vault-volumes
  <<: *mongo-volumes
  <<: *certmgr-volumes

Result:

---
x-node-volumes: &node-volumes
  node3_data:

x-vault-volumes:
  vault_data:

x-mongo-volumes: &mongo-volumes
  mongo_data:

x-certmgr-volumes:
  cert_data:

volumes:
  <<: *node-volumes
  <<: *mongo-volumes

Desired behavior

  • no change. Document is already formatteed

In this specific example, during YAML processing, the "volumes" map no longer contains all the volumes once yamlfix has processed the file.

Side node: Using a different method to aggregate the anchors produces correct results

volumes:
  <<: [*node-volumes, *vault-volumes, *mongo-volumes, *certmgr-volumes]

Environment

  • Ubuntu 20.04
  • Yamlfix version
$ yamlfix --version
              yamlfix version: 0.7.2
               python version: 3.8.10 (default, Jun  2 2021, 10:49:15)  [GCC 9.4.0]
                     platform: Linux-5.8.0-64-generic-x86_64-with-glibc2.29
@systemmonkey42 systemmonkey42 added the bug Something isn't working label Sep 4, 2021
@lyz-code
Copy link
Owner

lyz-code commented Sep 8, 2021

Hi @systemmonkey42, thanks for taking the time to open the issue. Sadly, I won't be able to look into it this month as I'm a little bit overloaded, maybe one of the other maintainers can jump in.

If you can't wait and have coding skills and some time, feel free to make a pull request.

@muripic
Copy link
Collaborator

muripic commented Sep 18, 2021

I've been running some tests to find the root cause for this and looks like it's coming from ruyaml. This is the only related issue I could find: pycontribs/ruyaml#50.

If I manage to fix it I'll send a PR to ruyaml.

@muripic
Copy link
Collaborator

muripic commented Sep 18, 2021

It was already fixed 😃 Only that they are not uploading the latest versions to pypi (I created an issue for this).

I upgraded the dependency and it works (build is failing due to issues with other dependencies but will try to fix them ASAP):
#122

@lyz-code
Copy link
Owner

Awesome! thanks @muripic :)

@lyz-code
Copy link
Owner

Until pycontribs/ruyaml#58 is resolved, I'll reopen this issue because we can't
hardcode dependencies from github in the setup.py as Pypi doesn't allow
them.

If you need that feature, please change the "ruyaml" line in the
setup.py with:

"ruyaml @ git+git://github.com/pycontribs/[email protected]#egg=ruyaml", # noqa E800

and run make install.

@lyz-code lyz-code reopened this Nov 26, 2021
lyz-code added a commit that referenced this issue Nov 26, 2021
Until pycontribs/ruyaml#58 is resolved, the issue
#120 will remain because we can't
hardcode dependencies from github in the `setup.py` because Pypi doesn't allow
them.

If you need that feature, please change the "ruyaml" line in the
`setup.py` with:

```python
"ruyaml @ git+git://github.com/pycontribs/[email protected]#egg=ruyaml", # noqa E800
```

and run `make install`.
@lyz-code
Copy link
Owner

It's merged already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants