python-betterproto
python-betterproto copied to clipboard
An empty message in a repeated field will be serialized to empty bytes
Given
syntax = "proto3";
message MessageA {
repeated float field_a = 1;
}
message MessageB {
repeated MessageA field_b = 1;
}
When
s = MessageB(field_b=[MessageA()]).SerializeToString()
Then s will be b'' and if call MessageB.FromString(s) the result will be MessageB() (different from MessageB(field_b=[MessageA()])).
But in some other protobuf libraries like Scalapb the serialized string will be \n\000. If call MessageB.FromString(b'\n\000') the result will be MessageB(field_b=[MessageA()])(the expected result).
Is this a bug?
It looks like we differ from the google implementation in this respect, so yes I'd say it is a bug. Thanks for reporting.
Fixed in #180