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

[BUG] nil pointer values are encoded as "null" and not decodable #217

Closed
1 task done
david-its opened this issue Aug 16, 2024 · 1 comment
Closed
1 task done

[BUG] nil pointer values are encoded as "null" and not decodable #217

david-its opened this issue Aug 16, 2024 · 1 comment
Labels

Comments

@david-its
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

it seems that optional fields using pointers to values are not handled by schema properly. e.g.:

        type S struct {
                Flag *bool `schema:"flag"`
        }

if we encode such an empty struct S{} it will result in url.Values{"flag": []string{"null"}}, which is not decodable by schema. The solution is to use omitempty. But it is easy to miss that. Can we panic on such fields to make sure omitempty is not missing? Another option is to handle correctly "null" values on decode.

Opinion?

Expected Behavior

Correctly encode/decode on empty struct with pointers.

Steps To Reproduce

No response

Anything else?

No response

@david-its david-its added the bug label Aug 16, 2024
@jaitaiwan
Copy link
Member

Going to close this as a duplicate of #216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants