Open
Description
What version of CUE are you using (cue version
)?
$ cue version cue version v0.13.0-alpha.1.0.20250314174817-9e333c606194 go version devel go1.25-21417518a9 2025-03-15 06:05:16 -0700 -buildmode exe -compiler gc DefaultGODEBUG decoratemappings=0,gotestjsonbuildtext=1,multipathtcp=0,randseednop=0,rsa1024min=0,tlsmlkem=0,x509rsacrt=0,x509usepolicies=0 CGO_ENABLED 1 GOARCH amd64 GOOS linux GOAMD64 v3 vcs git vcs.revision 9e333c606194edc184ffd518be71509a4b52bc1c vcs.time 2025-03-14T17:48:17Z vcs.modified false cue.lang.version v0.13.0
Does this issue reproduce with the latest stable release?
Yes.
What did you do?
exec cue export input.cue
cmp stdout export.json
exec cue vet -c input.cue export.json
-- input.cue --
foo: '\x00\x01\x02'
-- export.json --
{
"foo": "AAEC"
}
What did you expect to see?
This should succeed; exporting bytes to JSON results in a base64-encoded string, and I should be able to validate the data with the original CUE as a concrete schema.
What did you see instead?
> exec cue export input.cue
[stdout]
{
"foo": "AAEC"
}
> cmp stdout export.json
> exec cue vet -c input.cue export.json
[stderr]
foo: conflicting values "AAEC" and '\x00\x01\x02' (mismatched types string and bytes):
./export.json:2:12
./input.cue:1:6
[exit status 1]
I understand why this happens; our JSON decoder is currently not schema-aware, so it defaults to decoding the string "AAEC"
as a CUE string as-is, rather than noticing that the schema expects bytes
, meaning that it should do a base64 decode of the contents and end up with the CUE value '\x00\x01\x02'
.