Failed to parse unquoted string in mapping value containing `?`
Describe the bug A clear and concise description of what the bug is.
Note that any how to questions should be posted in the discussion board and not raised as an issue.
Version of yq: 4.45.1 Operating system: mac Installed via: docker/binary release/homebrew/snap/...
Input Yaml Concise yaml document(s) (as simple as possible to show the bug, please keep it to 10 lines or less) data1.yml:
# this works
foo: {bar: "a?bc"}
data2.yml:
# failed to parse
foo: {bar: a?bc}
Command The command you ran:
yq data2.yml
Actual behavior
Error: bad file 'pnpm-lock.yaml': yaml: did not find expected ',' or '}'
Expected behavior No error
Additional context
Yaml spec didn't mentioned anything about ? being special so it should be fine to be unquoted. https://yaml.org/spec/1.2.2/#822-block-mappings
I've tried a bunch of online yaml parser (like https://onlineyamltools.com/validate-yaml, https://jsonformatter.org/yaml-validator, https://yamlchecker.com/ and https://www.yamllint.com/) and they are fine with it.
Libraries like js-yaml (npm) and serde_yaml (rust) has no problem to parse this as well
+1 Would appreciate if this could be addressed. Some of our pnpm based projects would be unblocked if this were addressed.
@mikefarah have you had a chance to look at this one? yq fails to parse some pnpm yaml files with the latest pnpm v10
Analyzed the issue in yq and the root of the issue is actually the yaml parsing library: https://github.com/go-yaml/yaml Opened an issue there: https://github.com/go-yaml/yaml/issues/1070
However go-yaml is not maintained from 3 years, so chances of a fix there are low.
yq has a ticket to migrate to https://github.com/goccy/go-yaml here: https://github.com/mikefarah/yq/issues/2298
I tested go-yaml locally and it parses "foo: {bar: a?bc}" properly.
Thus this issue seems to be blocked by: https://github.com/mikefarah/yq/issues/2298
Is anyone working on https://github.com/mikefarah/yq/issues/2298?
This issue is also blocking: https://github.com/aspect-build/rules_js/issues/2100
Yeah this would be fixed by switching over to goccy (just tested). Sorry been busy with life and switching over is a big change 😅 - will have some more time to focus on yq in the coming weeks.
I've also raised this issue on yaml/go-yaml ; lets see if it gets any traction there now that it's supported by YAML org https://github.com/yaml/go-yaml/issues/36