-
Notifications
You must be signed in to change notification settings - Fork 74
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
Unmarshaling an invalid YAML is not throwing an error #112
Comments
try /close |
@dims: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Makes no difference if this is what you meant. package main
import (
"fmt"
"sigs.k8s.io/yaml"
)
const (
invalidYAML = `
test:
test1: hello
`
)
type yamlType struct {
Test string `yaml:"test"`
Test1 string `yaml:"test1"`
}
func main() {
var data1 interface{}
err := yaml.UnmarshalStrict([]byte(invalidYAML), &data1)
if err != nil {
fmt.Printf("Error1 %e", err)
}
fmt.Printf("data1: %+v\n", data1)
var data2 yamlType
err = yaml.UnmarshalStrict([]byte(invalidYAML), &data2)
if err != nil {
fmt.Printf("Error2 %e", err)
}
fmt.Printf("data2: %+v\n", data2)
} Output:
|
@dims I am not sure if this issue should remain closed as I was able to reproduce the bug with |
I too would want to know more about this behavior. Thanks for looking into it @kishorviswanathan 👍 |
Hi all, any update on this? |
Hi, I'm also following this thread, currently blocked by this upstream issue as I'm using OPA which relies |
Summary
Unmarshaling an invalid YAML with
yaml.Unmarshal
populates struct with invalid data rather than returning an error.Example
Output:
Expected output
The function should throw an error since the YAML is not valid.
Additional Information
The text was updated successfully, but these errors were encountered: