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 rewrites key 'on' to 'true' #148

Closed
kftsehk opened this issue Jun 27, 2022 · 3 comments
Closed

yq rewrites key 'on' to 'true' #148

kftsehk opened this issue Jun 27, 2022 · 3 comments

Comments

@kftsehk
Copy link

kftsehk commented Jun 27, 2022

happens in github action yaml

test.yaml:

on: push

test case:

yq --version
# yq 2.14.0

jq --version
# jq-1.6

yq -i -S -Y test.yaml && cat test.yaml
# 'true': push

the output is not equivalent to on: push, in my opinion, on to true transform should only be applied to values, not keys

Current workaround is

'on': push
@kislyuk
Copy link
Owner

kislyuk commented Jun 27, 2022

I appreciate the frustration. Unfortunately, this is a flaw in the underlying YAML language specification, not something that yq has any control over. We rely on PyYAML to interpret the language for us.

Luckily, YAML 1.2 eliminates this unintuitive behavior and treats on like any other string literal. Unfortunately, PyYAML does not support YAML 1.2 and progress in implementing it has been very slow (I opened yaml/pyyaml#116 almost 5 years ago and while a PR appeared about a year ago, it has not seen progress since).

PyYAML's most suitable competitor in this space, ruamel.yaml, does support YAML 1.2 but has its own issues and we currently have no plans to switch to it.

@kftsehk
Copy link
Author

kftsehk commented Jun 28, 2022

Thanks for explaining, the good side is there is a workaround.

@kislyuk kislyuk closed this as completed in a8eb2ed Jul 4, 2022
@kislyuk
Copy link
Owner

kislyuk commented Jul 4, 2022

v3.0.1 enables YAML 1.2 support, so this issue should now be fixed.

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