Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

panic running cue eval with struct in string interpolation #799

Closed
vikstrous2 opened this issue Feb 28, 2021 · 1 comment
Closed

panic running cue eval with struct in string interpolation #799

vikstrous2 opened this issue Feb 28, 2021 · 1 comment

Comments

@vikstrous2
Copy link

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

$ cue version v0.3.0-beta.5 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

I was trying to write some fancy generation code and accidentally put a struct in a key interpolation, which triggered a panic.

example.cue

{key: int32} & {"\({key: 123})": 123}

cue eval example.cue

panic: uncaught error [recovered]
        panic: uncaught error

goroutine 1 [running]:
cuelang.org/go/cmd/cue/cmd.recoverError(0xc0003c5ec0)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/root.go:221 +0x9c
panic(0xb62640, 0xd38fd0)
        <redacted>/.go/src/runtime/panic.go:965 +0x1b9
cuelang.org/go/internal/core/adt.(*OpContext).Unify(0xc000501790, 0xc000261b00, 0xc0003c4d05)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/internal/core/adt/eval.go:239 +0xee5
cuelang.org/go/internal/core/adt.(*nodeContext).completeArcs(0xc00025ce00, 0x5)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/internal/core/adt/eval.go:656 +0x13d
cuelang.org/go/internal/core/adt.(*nodeContext).postDisjunct(0xc00025ce00, 0x5)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/internal/core/adt/eval.go:589 +0x525
cuelang.org/go/internal/core/adt.(*nodeContext).expandDisjuncts(0xc00025ce00, 0xc000501705, 0xc00025ce00, 0x0, 0x203000)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/internal/core/adt/disjunct.go:151 +0x1508
cuelang.org/go/internal/core/adt.(*OpContext).Unify(0xc000501790, 0xc0002617a0, 0x5)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/internal/core/adt/eval.go:309 +0x477
cuelang.org/go/internal/core/adt.(*Vertex).Finalize(...)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/internal/core/adt/composite.go:441
cuelang.org/go/cue.(*Instance).Value(0xc00035c540, 0x6, 0xc0003940c0)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cue/instance.go:271 +0x65
cuelang.org/go/cmd/cue/cmd.buildInstances(0xc0003940c0, 0xc00043dc20, 0x1, 0x1, 0xc0004d0790, 0xc9c5d8, 0xd47be0)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/common.go:561 +0x131
cuelang.org/go/cmd/cue/cmd.(*buildPlan).instances(0xc00031a180, 0x0, 0x0)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/common.go:156 +0x58
cuelang.org/go/cmd/cue/cmd.runEval(0xc0003940c0, 0xc0003454e0, 0x1, 0x1, 0x0, 0x0)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/eval.go:113 +0x318
cuelang.org/go/cmd/cue/cmd.mkRunE.func1(0xc0002c5b80, 0xc0003454e0, 0x1, 0x1, 0x0, 0x0)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/root.go:46 +0x6c
github.com/spf13/cobra.(*Command).execute(0xc0002c5b80, 0xc0003454b0, 0x1, 0x1, 0xc0002c5b80, 0xc0003454b0)
        <redacted>/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc0002c5340, 0x0, 0x0, 0x0)
        <redacted>/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        <redacted>/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
cuelang.org/go/cmd/cue/cmd.(*Command).Run(0xc0003940c0, 0xd55af0, 0xc000126040, 0x0, 0x0)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/root.go:206 +0x65
cuelang.org/go/cmd/cue/cmd.mainErr(0xd55af0, 0xc000126040, 0xc00011e070, 0x2, 0x2, 0xc000068740, 0x468f45)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/root.go:145 +0x8d
cuelang.org/go/cmd/cue/cmd.Main(0xc00010e058)
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/cmd/root.go:127 +0x9b
main.main()
        <redacted>/go/pkg/mod/cuelang.org/go@v0.3.0-beta.5/cmd/cue/main.go:24 +0x25

What did you expect to see?

a human readable error

What did you see instead?

panic

@vikstrous2 vikstrous2 changed the title panic running cue eval panic running cue eval with struct in string interpolation Feb 28, 2021
@myitcv myitcv added this to the v0.3.0-evaluator-rewrite milestone Mar 1, 2021
cueckoo pushed a commit that referenced this issue Mar 5, 2021
These errorrs are already handled elsewhere and
leaving them unhandled violates an invariant.

Fixes #799.

Change-Id: Idef317fd873ead27f1836855b7b700c6679db735
@cueckoo cueckoo closed this as completed in 70e2f2e Mar 5, 2021
@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#799.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants