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

Behaviour for omitted fields in Unmarshal differs from json.Unmarshal #48

Closed
joris-bright opened this issue Nov 30, 2023 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@joris-bright
Copy link

Describe the bug
When unmarshalling a omitted github.com/google/uuid UUID a error is returned that is not there on json.Unmarshal

Expected behavior
Unmarshal should not be called for omitted fields

Links
https://go.dev/play/p/tih4SyA3Jca

@joris-bright joris-bright added the bug Something isn't working label Nov 30, 2023
@DQSevilla
Copy link
Contributor

Hey @joris-bright thanks for submitting this issue! Apologies for the delay in responding. We will schedule some time to investigate the source of the bug, but if you have time / a pressing need, feel free to open a PR and we'd be happy to review it!

@DQSevilla DQSevilla self-assigned this Jan 18, 2024
@joris-bright
Copy link
Author

Thanks for the response. It's not a high priority for me, just something I noticed. If I have some spare time I'll take a look, but probably not anytime soon.

@The-Cop
Copy link

The-Cop commented Jan 16, 2025

Hey @joris-bright, we looked into the issue.

According to jsonapi spec, id member is mandatory and should be a string.

Therefore, a valid string value is always expected for id. If you allowing empty/absent id, I suggest to explicitly state that by using jsonapi:omitempty tag (see this paragraph)

Slightly modified example demonstrating proper behavior: https://go.dev/play/p/X3AWls6S6WA

For non-primary members, omitted UUID value defaults to uuid.Nil.

@The-Cop The-Cop closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
@The-Cop The-Cop self-assigned this Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants