-
Notifications
You must be signed in to change notification settings - Fork 1k
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
The Marshal
method in the yaml.v3
package is generating potentially invalid yaml
#972
Comments
I did a little bit of investigation into this. Firstly, it seems to be a regression from Secondly, this issue has been reported a few times before. Duplicate issue numbers are #940, #963 and #968. There may be others. Here's a test program that demonstrates the issue with a few variations that may or may not be due to the same underlying cause: https://go.dev/play/p/DBp2CQrlBDa For the record, this is the problematic test data:
Not all the tests fail at all commits in the v3 history. Some commits at which behaviour seems to have changed: |
Also for the record, this doesn't appear to be to do with the Go struct marshaling logic. The same test failures occur when using anonymous types: https://go.dev/play/p/spthrUBMdwS |
Fixes konveyor/tackle2-addon-analyzer#24 The issues _seems_ to be a bug in yaml.v3. go-yaml/yaml#972 Also replaces: ``` if err != nil { h.Status(ctx, http.StatusBadRequest) return } ``` with ``` if err != nil { err = &BadRequestError{err.Error()} _ = ctx.Error(err) return } ``` so that the error is reported as BadRequest with an explaination of the error in the body instead of InternalServerError. --------- Signed-off-by: Jeff Ortel <jortel@redhat.com>
Please find a minimal reproduction here:- https://go.dev/play/p/HfTJF55cg69
Output:
If I change
gopkg.in/yaml.v3
togopkg.in/yaml.v2
in the import block, theUnmarshal
method works fine.The text was updated successfully, but these errors were encountered: