4 ms·
Ok but these messages are isomorphic on the wire: message enc { int foo = 1; SomeMessage bar = 2; } message dec { bool should_explode = 1;
by shereadsthenews 7y ago
Ok but these messages are isomorphic on the wire:
message enc {
int foo = 1;
SomeMessage bar = 2;
}
message dec {
bool should_explode = 1;
string why = 2;
}
You can successfully decode the latter from an encoding of the former.
- dweis 7y agoMinor nit, but not necessarily. For basically all values of SomeMessage, dec should fail to parse due to improperly encoded UTF8 data for field 2 (modulo some proto2 vs. proto3 and language binding implementation differences). Change field 2 to a bytes field instead of a string field and then yes.
- shereadsthenews 7y agoTrue but UTF8 enforcements was quite absent in all implementations until proto3, and the empty string would be a special case.
- shereadsthenews 7y agoI should mention that I consider this a feature not a bug. The isomorphism permits an endpoint to use ‘bytes submessage_i_dont_need_to_decode’ to cheaply handle nested message structures that need to be preserved but not inspected, such as in a proxy application.
- keymone 7y agoBool will decode from int’s encoding??