cue icon indicating copy to clipboard operation
cue copied to clipboard

encoding/yaml: YAML 1.2 directive causes "incompatible YAML document" error

Open rogpeppe opened this issue 1 year ago • 2 comments
trafficstars

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.

rogpeppe avatar Jul 31 '24 13:07 rogpeppe

Unfortunately this is hard-coded in yaml.v3: https://github.com/go-yaml/yaml/blob/f6f7691b1fdeb513f56608cd2c32c51f8194bf51/parserc.go#L1195-L1199

mvdan avatar Aug 13 '24 15:08 mvdan

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.

mvdan avatar Aug 13 '24 15:08 mvdan

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.

mvdan avatar Apr 14 '25 09:04 mvdan