Skip to content

Failed to parse unquoted string in mapping value containing ? #2294

Open
@fa93hws

Description

@fa93hws

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions