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

yamlfix breaks yaml loading on strings with question mark #188

Closed
ginevragaudioso opened this issue Dec 9, 2022 · 4 comments
Closed

yamlfix breaks yaml loading on strings with question mark #188

ginevragaudioso opened this issue Dec 9, 2022 · 4 comments
Labels
bug Something isn't working upstream

Comments

@ginevragaudioso
Copy link

ginevragaudioso commented Dec 9, 2022

I have the following yaml file:

---
- key: ['value?']

which loads correctly in python with pyyaml's yaml.safe_load.

yamlfix changes the file to

---
- key: [value?]

which cannot be loaded by pyyaml's yaml.safe_load, error being "expected ',' or ']', but got '?'"

yq breaks similarly with error "parse error: Invalid numeric literal at line 2, column 0"

It would be nice if yamlfix did not remove quotes on strings with question marks (and whatever other set of characters can cause this issue), or if there was a way to disable the feature to remove quotes entirely.

@lyz-code
Copy link
Owner

Hi @ginevragaudioso , thanks for taking the time to open the issue. I can confirm the behaviour and that it's a bug that should be fixed.

It makes sense to try to fix it upstream first (ruyaml is the library we use to do the main fix of the source code), so I've opened an issue on their repo.

@lyz-code lyz-code added bug Something isn't working upstream labels Dec 10, 2022
@marcules
Copy link
Contributor

@ginevragaudioso @lyz-code as a workaround, until this is fixed upstream, you could set the quote_basic_values option to True once this is merged -> #189 and the string value would remain quoted.

marcules added a commit to marcules/yamlfix that referenced this issue Dec 19, 2022
@ginevragaudioso
Copy link
Author

Thanks @marcules , that change would work great for us!

@lyz-code
Copy link
Owner

The patch is available since 1.2.0 therefore I'm closing the issue. If they ever fix it upstream you could remove the patch

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

No branches or pull requests

3 participants