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

Error when deserializing map with default (missing) value #318

Closed
peterhuene opened this issue Jul 10, 2018 · 3 comments
Closed

Error when deserializing map with default (missing) value #318

peterhuene opened this issue Jul 10, 2018 · 3 comments

Comments

@peterhuene
Copy link

peterhuene commented Jul 10, 2018

I'm using a protocol definition that has a message containing a map<string,string>.

When the map contains an empty value (e.g. "Foo" => ""), the C# protobuf implementation serializes field 1 (i.e. the "key") with a value of "Foo" and does not serialize a field 2 (i.e. the "value").

According to the protobuf documentation on default values, it appears this is completely legal and deserializers should treat the missing field as "default" (in this case, an empty string).

However, read_map_into explicitly checks for (_, None) and errors:

(None, _) | (_, None) => return Err(ProtobufError::WireError(WireError::IncompleteMap)),

The result is an IncompleteMap error instead of the expected map containing an empty string value.

@stepancheg
Copy link
Owner

Yes, you are right. Thank you!

MapField.cs
FieldCodec.cs

Going to fix it.

@stepancheg
Copy link
Owner

Published versions 2.0.3 and 1.7.4 with fix.

@peterhuene
Copy link
Author

Thanks for the quick fix!

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

No branches or pull requests

2 participants