go-yaml
go-yaml copied to clipboard
Parser fails to parse valid Yaml pattern `foo: {abc}`
The change in parser from PR https://github.com/goccy/go-yaml/pull/213 introduces a bug. Valid yaml is unable to be parsed.
We found this bug when trying to update from 1.8.9
-> 1.9.0
. The latest version of go-yaml still exhibits this bug.
The following is valid YAML according to http://yamllint.com/
foo: {abc}
The new parser returns an error. The existing parser in v1.8.9 resolves {abc}
as {"abc": null}
.
func TestParser(t *testing.T) {
source := `foo: {abc}`
_, err := parser.ParseBytes([]byte(source), parser.ParseComments)
if err != nil {
t.Errorf("unable to parse yaml: %q, error: %v", source, err)
}
}
Expected Behaviour: Parser properly tokenizes the valid foo: {abc}
source string.
Actual Behaviour: Got error.
unable to parse yaml: "foo: {abc}", error: [1:6] unterminated flow mapping
> 1 | foo: {abc}
^
Other Observations:
Decode seems to work with the right struct field tagging.