-
Notifications
You must be signed in to change notification settings - Fork 36
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
Missing fields are not handled correctly. #5
Comments
To be honest I have not had to deal with proto2 that much so did not really consider these scenarios. I suspect the marking of whether a field was set or not is (or should be) a feature provided by Prost. Does the protobuf spec describe how to handle an upgrade from proto2 to proto3? A cursory search did not show anything but I did find this stackoverflow post describing a similar scenario... |
Did you mean that you haven't had to deal with At least in Go, if you serialize an "empty" struct to JSON the result is fn main() {
println!("{}", bool::default());
println!("{}", u32::default());
println!("{}", i32::default());
println!("{}", f32::default());
println!("{:?}", Vec::<u32>::default());
println!("{:?}", Vec::<u8>::default());
println!("\"{}\"", String::default());
println!("{:?}", Option::<i32>::default());
} |
I just realized that the serde annotations are actually part of the example |
Since every thing is "optional" in proto3, it can be the case the not all fields exist in the JSON object. This is especially the case if one side of the exchange has a different version of the proto than the other and there are new fields or removed fields. This leads to a bunch of default values that should be used when something doesn't exist. I believe there is also some way to check if a value was unset or set to the same as the default, although maybe that is not consistent across languages.
The text was updated successfully, but these errors were encountered: