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

Closed
robharrop opened this issue Jul 12, 2022 · 1 comment
Closed
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).

@myitcv myitcv added the zGarden label Jun 13, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
cueckoo pushed a commit that referenced this issue Aug 5, 2024
In particular, to catch that interpreting them as JSON or YAML
currently results in panics.

The following patches will resolve these panics, showing a clear
improvement in the behavior of the added testscript.

For #1790.
For #2714.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I91cc75b7ae6eff50cf61c463d0778a41bec3e521
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198873
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Roger Peppe <[email protected]>
@cueckoo cueckoo closed this as completed in 30a5c79 Aug 6, 2024
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