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

eval: matchN buries error about missing required fields #3668

Closed
myitcv opened this issue Jan 9, 2025 · 3 comments
Closed

eval: matchN buries error about missing required fields #3668

myitcv opened this issue Jan 9, 2025 · 3 comments
Assignees
Labels
evaluator evalv3 issues affecting only the evaluator version 3 NeedsInvestigation

Comments

@myitcv
Copy link
Member

myitcv commented Jan 9, 2025

What version of CUE are you using (cue version)?

$ cue version
cue version v0.0.0-20250109154455-bbb2452ee698

go version go1.23.2
      -buildmode exe
       -compiler gc
  DefaultGODEBUG asynctimerchan=1,gotypesalias=0,httpservecontentkeepheaders=1,tls3des=1,tlskyber=0,x509keypairleaf=0,x509negativeserial=1
     CGO_ENABLED 1
          GOARCH arm64
            GOOS linux
         GOARM64 v8.0
             vcs git
    vcs.revision bbb2452ee698eb6043b0f8a29ef8e71d0f3400f0
        vcs.time 2025-01-09T15:44:55Z
    vcs.modified false
cue.lang.version v0.12.0

Does this issue reproduce with the latest release?

n/a - testing with tip

What did you do?

# case1
! exec cue export x.cue case1.cue
cmp stderr stderr.golden

# case2
! exec cue export x.cue case2.cue
cmp stderr stderr.golden

-- x.cue --
package x

#step: matchN(1, [{
	run!: string
}, {
	uses!: string
}])

#job: {
	steps!: [...#step]
}

let _template = {
	#run!: string
	run:   #run
}

w: #workflow & {
	jobs: test: steps: [
		_template,
	]
}
-- case1.cue --
package x

#workflow: {
	jobs!: [string]: #job
}
-- case2.cue --
package x

#workflow: {
	jobs!: [string]: matchN(1, [#job])
}
-- stderr.golden --
w.jobs.test.steps.0.#run: field is required but not present:
    ./x.cue:14:2
    ./x.cue:20:3
w.jobs.test.steps.0.run: incomplete value string:
    ./x.cue:14:9

What did you expect to see?

Passing test.

What did you see instead?

# case1 (0.013s)
# case2 (0.010s)
> ! exec cue export x.cue case2.cue
[stderr]
w.jobs.test: invalid value {steps:[{#run!:string,run:string}]} (does not satisfy matchN): 0 matched, expected 1:
    ./case2.cue:4:19
    ./case2.cue:4:26
    ./x.cue:19:14
[exit status 1]
> cmp stderr stderr.golden
diff stderr stderr.golden
--- stderr
+++ stderr.golden
@@ -1,4 +1,5 @@
-w.jobs.test: invalid value {steps:[{#run!:string,run:string}]} (does not satisfy matchN): 0 matched, expected 1:
-    ./case2.cue:4:19
-    ./case2.cue:4:26
-    ./x.cue:19:14
+w.jobs.test.steps.0.#run: field is required but not present:
+    ./x.cue:14:2
+    ./x.cue:20:3
+w.jobs.test.steps.0.run: incomplete value string:
+    ./x.cue:14:9

FAIL: /tmp/testscript2944458678/repro.txtar/script.txtar:7: stderr and stderr.golden differ

Note that this appears to be different from https://cuelang.org/issue/3651 because I still see the same behaviour when testing against https://cuelang.org/cl/1206950/1

Note also the only diff between case1 and case2 is the "wrapping" with an additional matchN:

--- case1.cue   2025-01-09 17:36:32.083576069 +0000
+++ case2.cue   2025-01-09 17:36:32.083576069 +0000
@@ -1,5 +1,5 @@
 package x

 #workflow: {
-       jobs!: [string]: #job
+       jobs!: [string]: matchN(1, [#job])
 }
@mpvl
Copy link
Member

mpvl commented Jan 14, 2025

This is marked as evalv3, but from the test it doesn't appear to be an issue specific to evalv3.

@myitcv
Copy link
Member Author

myitcv commented Jan 14, 2025

Let me take a look. For some reason I can't reproduce the original problem that I had (this issue is a much-reduced form of a wider issue).

@myitcv myitcv self-assigned this Jan 14, 2025
@myitcv
Copy link
Member Author

myitcv commented Jan 15, 2025

I think there must be an element of user error here (i.e. my fault). I haven't managed to replay the sequence of steps that lead to me raising this issue. Specifically, I'm fairly sure I got here because evalv3 failed on the cuelang.org CI setup. But I now can't reproduce the problem. So I'll close this issue for now, and re-open if required.

@myitcv myitcv closed this as completed Jan 15, 2025
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 NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

2 participants