-
Notifications
You must be signed in to change notification settings - Fork 1.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
Reading empty file causes Decode to return error #805
Comments
this should work around the following go-yaml issue: go-yaml/yaml#805
this should work around the following go-yaml issue: go-yaml/yaml#805
this should work around the following go-yaml issue: go-yaml/yaml#805
Also, modify `empty_config_yml` because with yaml.v3 reading empty file causes Decode to return EOF error, as described in go-yaml/yaml#805 issue.
Also, modify `empty_config_yml` because with yaml.v3 reading empty file causes Decode to return EOF error, as described in go-yaml/yaml#805 issue. Signed-off-by: Mikel Olasagasti Uranga <[email protected]>
Also, modify `empty_config_yml` because with yaml.v3 reading empty file causes Decode to return EOF error, as described in go-yaml/yaml#805 issue. Signed-off-by: Mikel Olasagasti Uranga <[email protected]>
I originally thought this was a bug as well, and went to try to fix it, but now I believe it might be working as intended. https://pkg.go.dev/gopkg.in/yaml.v2#Decoder.Decode says
Compare https://pkg.go.dev/gopkg.in/yaml.v3#Unmarshal
Decode reads one document at a time, whereas Unmarshal only reads the first document. Because of this I imagine some clients of Decode() expect to loop until EOF, thus an empty file cannot return I found this out by trying to do the naive thing and Decode() return Note that the original tests explicitly call out this discrepancy between My view then is to call this out in the documentation (I'll write something up now) and leave the behavior unchanged. Open to other suggestions though. |
Also, modify `empty_config_yml` because with yaml.v3 reading empty file causes Decode to return EOF error, as described in go-yaml/yaml#805 issue. Signed-off-by: Mikel Olasagasti Uranga <[email protected]>
Also, modify `empty_config_yml` because with yaml.v3 reading empty file causes Decode to return EOF error, as described in go-yaml/yaml#805 issue. Signed-off-by: Mikel Olasagasti Uranga <[email protected]>
In yaml.v3, when reading from empty file, the Decode function returns io.EOF. It should behave just like Unmarshal function, which will happily unmarshal from empty string, without any errors.
The text was updated successfully, but these errors were encountered: