-
Notifications
You must be signed in to change notification settings - Fork 70
Open
Description
When decoding a message using a oneof with a field that has not been defined by the code doing the decoding, no error is thrown. Instead, the field has the nil value. It would be better if the decode function would fail with an explicit error instead of giving an invalid result.
Example:
one_of.proto
message SampleOneofMsg {
optional string one = 1;
oneof foo {
string body = 3;
uint32 code = 4;
}
}
message SampleOneofExtMsg {
optional string one = 1;
oneof foo {
string body = 3;
uint32 code = 4;
string meta = 5;
}
}
This code:
msg_ext = Msgs.SampleOneofExtMsg.new(foo: {:meta, "meta"}, one: "test")
enc_msg = Protobuf.Serializable.serialize(msg_ext)
IO.inspect(Msgs.SampleOneofMsg.decode(enc_msg))
will return:
%Protobuf.Oneof.Test.Msgs.SampleOneofMsg{foo: nil, one: "test"}
Metadata
Metadata
Assignees
Labels
No labels