-
Notifications
You must be signed in to change notification settings - Fork 352
Open
Labels
Description
What version of CUE are you using (cue version)?
$ cue version
cue version v0.0.0-20230428121230-80d6ea032057
go version devel go1.21-3ed8a1e629 Tue Mar 28 05:41:44 2023 +0000
-buildmode exe
-compiler gc
DefaultGODEBUG panicnil=1
CGO_ENABLED 1
GOARCH amd64
GOOS linux
GOAMD64 v1
vcs git
vcs.revision 80d6ea032057b40e405eefab6015e92bbc5cc2a5
vcs.time 2023-04-28T12:12:30Z
vcs.modified false
Does this issue reproduce with the latest stable release?
Yes
What did you do?
# Without the disjunction, an error message points to the problematic line.
! exec cue export -e _x ok.cue
stderr '"\^#'
# With the disjunction, there is no error that points to the problematic line.
exec cue export -e _x not_ok.cue
stderr '"\^#'
-- ok.cue --
_x: #Ref & {
type: "ref"
ref: "foo"
}
#Ref: string | {
type!: "ref"
ref!: =~ "^#"
}
-- not_ok.cue --
_x: #Object & {
type: "object"
property: {
type: "array"
items: {
type: "ref"
ref: "foo"
}
}
}
#Object: {
type!: "object"
property!: #Ref | #Array
}
#Array: {
type!: "array"
items: #Ref
}
#Ref: string | {
type!: "ref"
// This is the problem line, but the error messages don't mention it at all!
ref!: =~ "^#"
}
What did you expect to see?
A passing test.
What did you see instead?
# Without the disjunction, an error message points to the problematic line. (0.021s)
# With the disjunction, there is no error that points to the problematic line. (0.014s)
> exec cue export -e _x not_ok.cue
[stderr]
_x.property: 2 errors in empty disjunction:
_x.property: conflicting values string and {type:"array",items:{type:"ref",ref:"foo"}} (mismatched types string and struct):
./not_ok.cue:3:12
./not_ok.cue:22:7
_x.property.type: conflicting values "ref" and "array":
./not_ok.cue:1:5
./not_ok.cue:4:9
./not_ok.cue:14:13
./not_ok.cue:23:9
[exit status 1]
FAIL: /tmp/testscript4020124080/x.txtar/script.txtar:6: unexpected command failure
The actual problem here is that there is a conflict between _x.ref and #Ref.ref, but that issue isn't surfaced at all in the errors that are printed. In larger configurations, this can make it very hard to pinpoint the reason for a validation failure.
Reactions are currently unavailable