Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evalv3 regression where schema used via LookupPath and FillPath causes "field not allowed" #3826

Open
mvdan opened this issue Mar 18, 2025 · 3 comments
Assignees
Labels
evaluator evalv3 issues affecting only the evaluator version 3 unity-win bugs found thanks to projects added to Unity

Comments

@mvdan
Copy link
Member

mvdan commented Mar 18, 2025

# Uncomment as needed:
# exec go mod edit -replace=cuelang.org/go=/home/mvdan/src/c/cue

exec go mod tidy

env CUE_EXPERIMENT=evalv3=0
exec go run main.go

env CUE_EXPERIMENT=evalv3=1
exec go run main.go
-- go.mod --
module test

go 1.23

require cuelang.org/go v0.13.0-alpha.1.0.20250318153901-c479844b8d7a
-- main.go --
package main

import (
	"fmt"
	"os"

	"cuelang.org/go/cue"
	"cuelang.org/go/cue/cuecontext"
)

func main() {
	ctx := cuecontext.New()

	v := ctx.CompileString(`
		_schema: _
		_schema
		apiVersion: "foo"
		spec: group: "foo"
	`)
	schema := ctx.CompileString(`
		#Schema: {
			spec!: group!: string
		}
	`).LookupPath(cue.MakePath(cue.Def("#Schema")))

	v = v.FillPath(cue.MakePath(cue.Hid("_schema", "_")), schema)

	if err := v.Validate(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	fmt.Println("Success")
	os.Exit(0)
}

As of c479844:

> env CUE_EXPERIMENT=evalv3=0
> exec go run main.go
[stdout]
Success
> env CUE_EXPERIMENT=evalv3=1
> exec go run main.go
[stdout]
apiVersion: field not allowed
[stderr]
exit status 1
[exit status 1]
FAIL: repro-go.txtar:10: unexpected command failure
@mvdan mvdan added evaluator evalv3 issues affecting only the evaluator version 3 unity-win bugs found thanks to projects added to Unity labels Mar 18, 2025
@mvdan
Copy link
Member Author

mvdan commented Mar 18, 2025

Here is a pure CUE reproducer:

# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue export

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
exec cue export

-- input.cue --
package p

_schema
apiVersion: "foo"
spec: group: "foo"

#Schema: {
	spec!: group!: string
}

_schema: #Schema
# With the old evaluator. (0.023s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue export
[stdout]
{
    "spec": {
        "group": "foo"
    },
    "apiVersion": "foo"
}
# With the new evaluator. (0.048s)
> env CUE_EXPERIMENT=evalv3=1
> exec cue export
[stderr]
apiVersion: field not allowed:
    ./input.cue:4:1
[exit status 1]
FAIL: repro-evalv3.txtar:7: unexpected command failure

@mpvl mpvl self-assigned this Mar 19, 2025
cueckoo pushed a commit that referenced this issue Mar 19, 2025
Issue #3826

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I819dd2859060a32bc556e4bbd5a518e14dabd1ee
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211799
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
@mvdan
Copy link
Member Author

mvdan commented Mar 19, 2025

I will reopen this one if that's okay, because it turns out that you fixed my pure CUE reproducer in my last comment, but the original Go code is still broken on evalv3.

I tried reducing it into pure CUE again, and I think I have it once again:

# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue export

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
exec cue export

-- input.cue --
package p

apiVersion: "foo"
spec: group: "foo"

#Schema

#Schema: close({
	spec!: group!: string
})

As of 2c002ae:

# With the old evaluator. (0.010s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue export
[stdout]
{
    "spec": {
        "group": "foo"
    },
    "apiVersion": "foo"
}
# With the new evaluator. (0.023s)
> env CUE_EXPERIMENT=evalv3=1
> exec cue export
[stderr]
apiVersion: field not allowed:
    ./input.cue:3:1

@mvdan mvdan reopened this Mar 19, 2025
cueckoo pushed a commit that referenced this issue Mar 20, 2025
Another reducer for the same test.

Issue #3826

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: Ie641254eb64bee58a21b368b7d0ba82ac8d819cb
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211845
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
cueckoo pushed a commit that referenced this issue Mar 20, 2025
If a reference was closed multiple times within a
single enclosingEmbed group, it could create
multiple closings, especially if hasOuter was
still false. By setting it to true we prevent
a new group from being created once an
enclosingEmbed has been closed.

Issue #3826

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I7d66fdb722aa88e0ac212030ac3fbf393ec7879b
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211846
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
@mvdan
Copy link
Member Author

mvdan commented Mar 20, 2025

Leaving this open because the original Go code still fails as of e311d45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluator evalv3 issues affecting only the evaluator version 3 unity-win bugs found thanks to projects added to Unity
Projects
None yet
Development

No branches or pull requests

2 participants