cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.03k stars 287 forks source link

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

Open rogpeppe opened 1 month ago

rogpeppe commented 1 month ago

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.

mvdan commented 1 month ago

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

mvdan commented 1 month ago

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.