You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
Yes
What did you do?
Consider the following, where the CUE module in the m directory is the result of downloading a module that has previously been published somewhere (e.g. an OCI registry). Note the module is missing a language.version: either because it was published prior to v0.8.0 (which introduced that field via v0.8.0-alpha.3) or because a tool using the Go API did not add such a line. The Go code below is in effect a simulation of a tool like Timoni (https://timoni.sh/) that uses the Go API, and consumes CUE modules that have been published someone, but not published via the mechanism that became the default in v0.9.0.
go mod tidy
go run .
cmp stdout stdout.golden
-- go.mod --
module mod.example
go 1.22.3
require cuelang.org/go v0.9.0
-- m/cue.mod/module.cue --
module: "mod.example/blah"
-- m/blah.cue --
package blah
blah: 42
-- main.go --
package main
import (
"fmt"
"log"
"cuelang.org/go/cue/cuecontext"
"cuelang.org/go/cue/load"
)
func main() {
ctx := cuecontext.New()
bis := load.Instances([]string{"."}, &load.Config{
Dir: "./m",
})
v := ctx.BuildInstance(bis[0])
if err := v.Err(); err != nil {
log.Fatal(err)
}
fmt.Println(v)
}
-- stdout.golden --
{
blah: 42
}
What did you expect to see?
The test to pass.
What did you see instead?
> go mod tidy
> go run .
[stderr]
main.go:18: no language version declared in module.cue
exit status 1
[exit status 1]
FAIL: /tmp/testscript3849746612/repro.txtar/script.txtar:2: unexpected go command failure
When we were considering the enforcing of language.version, we did not consider the case of pre-existing modules that have been published somewhere without a language.version. Instead our analysis focussed on consideration of those who had been using the modules experiment that started with the v0.8.0 alphas. This was a mistake. Because this Go code not working results in a breaking change for pre-existing modules of CUE that are published (which one should read as "and would need to be republished to add a language.version). This affects tools written against the Go API which themselves provide a means of downloading a published CUE module.
We are therefore proposing a fix via a flag for cue/load.Config that, when enabled, will enabled legacy modules without a language.version to be loaded.
The text was updated successfully, but these errors were encountered:
In some cases, we want to be able to accept legacy module files (module
files lacking a major version) because there's no easy way to fix them
by running `cue mod fix`. When running the cue command, `cue mod fix`
should always be a possibility - the problem exists principally when
using `cue/load` directly.
We don't want to make this the default, because interpreting module
files in this way is problematic, as it will discard fields that are
legitimately part of the non-legacy module schema.
So we add a boolean field that explicitly enables this behavior.
Fixes#3219.
Signed-off-by: Roger Peppe <rogpeppe@gmail.com>
Change-Id: I24d66eb680be3267adbe0a972705cc3414936362
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196156
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1196230
Reviewed-by: Paul Jolly <paul@myitcv.io>
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
Consider the following, where the CUE module in the
m
directory is the result of downloading a module that has previously been published somewhere (e.g. an OCI registry). Note the module is missing alanguage.version
: either because it was published prior to v0.8.0 (which introduced that field via v0.8.0-alpha.3) or because a tool using the Go API did not add such a line. The Go code below is in effect a simulation of a tool like Timoni (https://timoni.sh/) that uses the Go API, and consumes CUE modules that have been published someone, but not published via the mechanism that became the default in v0.9.0.What did you expect to see?
The test to pass.
What did you see instead?
When we were considering the enforcing of
language.version
, we did not consider the case of pre-existing modules that have been published somewhere without alanguage.version
. Instead our analysis focussed on consideration of those who had been using the modules experiment that started with the v0.8.0 alphas. This was a mistake. Because this Go code not working results in a breaking change for pre-existing modules of CUE that are published (which one should read as "and would need to be republished to add alanguage.version
). This affects tools written against the Go API which themselves provide a means of downloading a published CUE module.We are therefore proposing a fix via a flag for
cue/load.Config
that, when enabled, will enabled legacy modules without alanguage.version
to be loaded.The text was updated successfully, but these errors were encountered: