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

encoding/yaml: Panic when unmarshalling YAML content that is only comments #1790

Open
robharrop opened this issue Jul 12, 2022 · 1 comment · May be fixed by #1807
Open

encoding/yaml: Panic when unmarshalling YAML content that is only comments #1790

robharrop opened this issue Jul 12, 2022 · 1 comment · May be fixed by #1807
Labels

Comments

@robharrop
Copy link

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

$ cue version
cue version v0.4.3 darwin/arm64

Also tested on cue version v0.4.4-0.20220706163258-2795dcc4db87

Does this issue reproduce with the latest release?

Yes.

What did you do?

Attempt to unmarshal YAML content that is just a comment using encoding/yaml.

Given test.cue with:

import "encoding/yaml"

out: yaml.Unmarshal("#test")

Running cue eval test.cue

What did you expect to see?

Certainly not a panic. Likely an empty output or bottom?

What did you see instead?

A panic:

panic: assertion failed: nil return value: unspecified error [recovered]
	panic: assertion failed: nil return value: unspecified error

goroutine 1 [running]:
cuelang.org/go/cmd/cue/cmd.recoverError(0x140005bfe70)
	cuelang.org/go/cmd/cue/cmd/root.go:229 +0x98
panic({0x1035261c0, 0x1400071c860})
	runtime/panic.go:838 +0x204
cuelang.org/go/internal/core/adt.Assertf(...)
	cuelang.org/go/internal/core/adt/context.go:93
cuelang.org/go/internal/core/adt.(*OpContext).evaluateRec(0x14000719ad0, 0x1400011f7c0, {0x103610a68, 0x14000113140}, 0x78?)
	cuelang.org/go/internal/core/adt/context.go:582 +0x280
...
@robharrop robharrop added NeedsInvestigation Triage Requires triage/attention labels Jul 12, 2022
@mvdan mvdan added NeedsFix and removed NeedsInvestigation Triage Requires triage/attention labels Jul 19, 2022
@critterjohnson
Copy link

This actually applies to not just comments, but any time yaml.Unmarshal() is called on anything that returns no actual value (like an empty string).

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

Successfully merging a pull request may close this issue.

4 participants