cue
cue copied to clipboard
encoding/yaml: YAML 1.2 directive causes "incompatible YAML document" error
What version of CUE are you using (cue version)?
$ cue version v0.9.2
Does this issue reproduce with the latest stable release?
Yes
What did you do?
exec cue export x.yaml
-- x.yaml --
%YAML 1.2
---
a: 1
What did you expect to see?
A passing test.
What did you see instead?
> exec cue export x.yaml
[stderr]
$WORK/x.yaml: found incompatible YAML document
[exit status 1]
FAIL: /tmp/testscript3168613588/x.txtar/script.txtar:1: unexpected command failure
YAML files do seem to hold directives like this in the wild so perhaps we should support it.
Unfortunately this is hard-coded in yaml.v3: https://github.com/go-yaml/yaml/blob/f6f7691b1fdeb513f56608cd2c32c51f8194bf51/parserc.go#L1195-L1199
Tracked upstream at https://github.com/go-yaml/yaml/issues/298, raised by... you :)
I think this is one of the issues that can only be properly resolved by fixing or swapping the yaml dependency.
It looks like https://github.com/goccy/go-yaml is maintained and supports YAML 1.2 and 1.3 properly, so I think that's our solution - see https://github.com/cue-lang/cue/issues/3880.