You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you define a proto message without any fields but return the message populated with fields in the grpc server,
the decoder won't read the fields and the buffer will get out of sync
To reproduce:
message GrpcTest {
}
// Generate client code
//Update proto
message GrpcTest {
string test = 1;
}
// Generate server code
The text was updated successfully, but these errors were encountered:
This is just how protobuf works. See unknown fields for proto2 and proto3. This library supports unknown fields and you can access and preserve them when decoding/encoding binary.
Unknown fields only work if the message has fields implemented. In the case of an empty message, the generated de-serialization logic is the following:
This implementation does not handle unknown field, it does not progress the buffer, and therefore ends up in a corrupt state.
The correct generated reader should be something of the like:
let message = target ?? this.create(), end = reader.pos + length;
while (reader.pos < end) {
let [fieldNo, wireType] = reader.tag();
switch (fieldNo) {
default:
let u = options.readUnknownField;
if (u === "throw")
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
let d = reader.skip(wireType);
if (u !== false)
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
}
}
return message;
If you define a proto message without any fields but return the message populated with fields in the grpc server,
the decoder won't read the fields and the buffer will get out of sync
To reproduce:
message GrpcTest {
}
// Generate client code
//Update proto
message GrpcTest {
string test = 1;
}
// Generate server code
The text was updated successfully, but these errors were encountered: