cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.13k stars 294 forks source link

panic: nil value [recovered] when upgrading to 0.3.0-beta.3 #672

Closed cueckoo closed 3 years ago

cueckoo commented 3 years ago

Originally opened by @binarylogic in https://github.com/cuelang/cue/issues/672

After opening #633 and getting stellar help (thank you!), we attempted to upgrade to 0.3.0-beta.3 and received the error below. https://github.com/timberio/vector/pull/6220 contains the changes suggested in https://github.com/cuelang/cue/issues/633#issuecomment-759299988.

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

$ cue version
cue version 0.3.0-beta.3 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

I applied the changes mentioned in https://github.com/cuelang/cue/issues/633#issuecomment-759299988, you can see them at https://github.com/timberio/vector/pull/6220. To reproduce:

  1. git checkout git@github.com:timberio/vector.git
  2. cd vector
  3. git checkout upgrade-cue (see https://github.com/timberio/vector/pull/6220)
  4. cue export docs/**/*.cue

What did you expect to see?

The standard JSON output.

What did you see instead?

panic: nil value [recovered]
    panic: nil value

goroutine 1 [running]:
cuelang.org/go/cmd/cue/cmd.recoverError(0xc00239fec0)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/root.go:221 +0x95
panic(0x1798f40, 0x19753c0)
    /usr/local/go/src/runtime/panic.go:969 +0x1b9
cuelang.org/go/internal/core/adt.(*Unifier).evaluate(0xc0000ec1d8, 0xc0000ec1c0, 0xc00402a870, 0xaa5ed03, 0xc0021adce0, 0x203001)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:167 +0x371
cuelang.org/go/internal/core/adt.(*OpContext).evalState(0xc0000ec1c0, 0x1999680, 0xc0021adce0, 0x12cbd03, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/context.go:594 +0x247
cuelang.org/go/internal/core/adt.(*OpContext).node(0xc0000ec1c0, 0x198c6c0, 0xc0021c2820, 0x1999680, 0xc0021adce0, 0xc00001e000, 0x17e5480)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/context.go:734 +0x5f
cuelang.org/go/internal/core/adt.(*SelectorExpr).resolve(0xc0021c2820, 0xc0000ec1c0, 0xc0015c8510)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/expr.go:706 +0x65
cuelang.org/go/internal/core/adt.(*OpContext).Resolve(0xc0000ec1c0, 0xc0051195e0, 0x19939c0, 0xc0021c2820, 0xc0021c2820, 0x1)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/context.go:401 +0xe8
cuelang.org/go/internal/core/adt.(*nodeContext).evalExpr(0xc005f82a80, 0xc0051195e0, 0x198c6c0, 0xc0021c2820, 0xc003286f80, 0x0)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:1112 +0x51f
cuelang.org/go/internal/core/adt.(*nodeContext).addExprConjunct(0xc005f82a80, 0xc0051195e0, 0x198c6c0, 0xc0021c2820, 0xc003286f80, 0x0)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:1082 +0x211
cuelang.org/go/internal/core/adt.(*nodeContext).addExprConjunct(0xc005f82a80, 0xc0051195e0, 0x198c280, 0xc0021c2b00, 0xc003286f80, 0x0)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:1065 +0x2f3
cuelang.org/go/internal/core/adt.(*Unifier).Unify(0xc0000ec1d8, 0xc0000ec1c0, 0xc00405e480, 0x180e105)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:269 +0x319
cuelang.org/go/internal/core/adt.(*nodeContext).completeArcs(0xc0045c4380, 0x5)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:600 +0x136
cuelang.org/go/internal/core/adt.(*nodeContext).postDisjunct(0xc0045c4380, 0xc004029a05)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:546 +0x47b
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc0045c4380, 0xc004029c05, 0xc0045c4380, 0x0, 0xc005782800)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/disjunct.go:142 +0x1032
cuelang.org/go/internal/core/adt.(*Unifier).Unify(0xc0000ec1d8, 0xc0000ec1c0, 0xc004029c20, 0x180e105)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:329 +0x49a
cuelang.org/go/internal/core/adt.(*nodeContext).completeArcs(0xc0031b0380, 0x5)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:600 +0x136
cuelang.org/go/internal/core/adt.(*nodeContext).postDisjunct(0xc0031b0380, 0xc005b0e305)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:546 +0x47b
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc0031b0380, 0xc000939e05, 0xc0031b0380, 0x0, 0xc0005c0100)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/disjunct.go:142 +0x1032
cuelang.org/go/internal/core/adt.(*Unifier).Unify(0xc0000ec1d8, 0xc0000ec1c0, 0xc000939ef0, 0x180e105)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:329 +0x49a
cuelang.org/go/internal/core/adt.(*nodeContext).completeArcs(0xc000036700, 0x5)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:600 +0x136
cuelang.org/go/internal/core/adt.(*nodeContext).postDisjunct(0xc000036700, 0xc000036705)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:546 +0x47b
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc000036700, 0xc0012f0105, 0xc000036700, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/disjunct.go:142 +0x1032
cuelang.org/go/internal/core/adt.(*Unifier).Unify(0xc0000ec1d8, 0xc0000ec1c0, 0xc0012f01b0, 0x180e105)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:329 +0x49a
cuelang.org/go/internal/core/adt.(*nodeContext).completeArcs(0xc0000b6700, 0x5)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:600 +0x136
cuelang.org/go/internal/core/adt.(*nodeContext).postDisjunct(0xc0000b6700, 0xc0000b6705)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:546 +0x47b
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc0000b6700, 0xc0000dc005, 0xc0000b6700, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/disjunct.go:142 +0x1032
cuelang.org/go/internal/core/adt.(*Unifier).Unify(0xc0000ec1d8, 0xc0000ec1c0, 0xc0000dc090, 0x180e105)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:329 +0x49a
cuelang.org/go/internal/core/adt.(*nodeContext).completeArcs(0xc0000b6380, 0x5)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:600 +0x136
cuelang.org/go/internal/core/adt.(*nodeContext).postDisjunct(0xc0000b6380, 0xc0007f2d05)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:546 +0x47b
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc0000b6380, 0xc0019e5005, 0xc0000b6380, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/disjunct.go:142 +0x1032
cuelang.org/go/internal/core/adt.(*Unifier).Unify(0xc0000ec1d8, 0xc0000ec1c0, 0xc0019e5050, 0xc0000ec105)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/eval.go:329 +0x49a
cuelang.org/go/internal/core/adt.(*Vertex).Finalize(...)
    /Users/mpvl/Documents/dev/release/cue/internal/core/adt/composite.go:405
cuelang.org/go/cue.(*Instance).Value(0xc001a9a460, 0x6, 0xc00032b880)
    /Users/mpvl/Documents/dev/release/cue/cue/instance.go:271 +0x6c
cuelang.org/go/cmd/cue/cmd.buildInstances(0xc00032b880, 0xc001a86d68, 0x1, 0x1, 0x17c79c0, 0xc000338660, 0xc0002bdb58)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/common.go:552 +0x131
cuelang.org/go/cmd/cue/cmd.(*buildPlan).instances(0xc000388000, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/common.go:156 +0x58
cuelang.org/go/cmd/cue/cmd.runExport(0xc00032b880, 0xc000379800, 0x15f, 0x15f, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/export.go:114 +0x1be
cuelang.org/go/cmd/cue/cmd.mkRunE.func1(0xc000348000, 0xc000379800, 0x15f, 0x15f, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/root.go:46 +0x6c
github.com/spf13/cobra.(*Command).execute(0xc000348000, 0xc000378000, 0x15f, 0x180, 0xc000348000, 0xc000378000)
    /Users/mpvl/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x47c
github.com/spf13/cobra.(*Command).ExecuteC(0xc0000e5080, 0x0, 0x0, 0x0)
    /Users/mpvl/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
    /Users/mpvl/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
cuelang.org/go/cmd/cue/cmd.(*Command).Run(0xc00032b880, 0x1997280, 0xc00003a0b8, 0x0, 0x0)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/root.go:206 +0x65
cuelang.org/go/cmd/cue/cmd.mainErr(0x1997280, 0xc00003a0b8, 0xc000031810, 0x160, 0x17f, 0x18d9dc8, 0xc0002bdf48)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/root.go:145 +0x8a
cuelang.org/go/cmd/cue/cmd.Main(0xc000100058)
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/cmd/root.go:127 +0x9c
main.main()
    /Users/mpvl/Documents/dev/release/cue/cmd/cue/main.go:24 +0x25
cueckoo commented 3 years ago

Original reply by @mpvl in https://github.com/cuelang/cue/issues/672#issuecomment-768047674

Turns out to be a simple fix. Coming up.