bug: proto3 default map key breaks deserialization
conradhappeliv opened this issue · 1 comments
conradhappeliv commented
I have a proto3 map field with int32
keys:
message GameState {
map<int32, PlayerData> player_data = 6;
}
This normally works, except when the map key is 0
.
For example, this code is broken because from_bytes
returns error REQUIRED_FIELDS
:
var s = API.GameState.new()
s.add_player_data(0)
print(s.from_bytes(s.to_bytes())) # Prints -9, aka "REQUIRED_FIELDS".
However, when I change the map key to something else (e.g. 1
), deserialization works fine.
I assume this is due to improper handling of default values as map keys. I haven't tested it, but I assume the same issue is present for other default types (e.g. empty strings).
oniksan commented
Bug fixed in v 0.5.0