-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
jsonpb Marshal and Unmarshal should return error on missing required field #440
Comments
\cc @cybrcodr |
JSON serialization is only described in proto3 page -- Sadly a "required" field does not apply in proto3. If we do change the unmarshaler to respect required for proto2, it may break current users. We can add an option to check for required fields instead. |
@cybrcodr, how would it break current users? |
If an existing application is relying on the current behavior of not returning error on missing required fields, and it switches to returning an error, then it may break that app. Anyways, I think chances are probably small though I could be totally wrong on this. I don't have the bandwidth to work on this, but am open to review a PR. |
Btw, for consistency, if we do change this behavior to return an error value if required field is not in set on Unmarshal, we should also change Marshal to return error if required field is not set before Marshal'ing. |
Sure. And that is how it is supposed to be IMO :-\ |
Fixed in #472 |
If I have a message in *.proto file with required field and I try to convert json representation of this message to message itself, I would expect my Unmarshaller to check for required fields and to give an error if required fields are not in json representation. But jsonpb does not check that.
The text was updated successfully, but these errors were encountered: