-
Notifications
You must be signed in to change notification settings - Fork 474
std.parseYaml fails on non-standard yaml feature, supported in other implementations #1109
Description
Consider this input:
std.parseYaml("0777")cpp-jsonnet outputs:
Something went wrong during jsonnet_evaluate_snippet, please report this: [json.exception.parse_error.101] parse error at line 1, column 5: syntax error while parsing array - unexpected number literal; expected ']'
Segmentation fault
go-jsonnet outputs:
511
jrsonnet outputs:
511
sjsonnet outputs:
sjsonnet.Error: Internal error: scala.MatchError: null
Caused by: scala.MatchError: null
But this is caused by sjsonnet only supporting objects in parseYaml, so std.parseYaml("a: 0777") works:
{
"a": 511
}
Why does it happens?
Well, there is two yaml specs: yaml 1.1, and yaml 1.2, and even if it is a minor update by semver... It isn't a semver.
The one breaking change in yaml 1.2, is that octal literals in 0777 form are now forbidden, 0o777 should be used instead.
However, many yaml implementations are not following the spec, especially golang, which will even output octals in 0777 format: go-yaml/yaml#420
For jrsonnet, I had to modify serde-yaml rust library to also accept this input: dtolnay/serde-yaml#225
And rapidyaml did not implemented this compatibility feature: biojppm/rapidyaml#291