Sending InvalidProtocolBufferException to client side

113 views
Skip to first unread message

shu...@mediaiqdigital.com

unread,
Mar 7, 2018, 2:55:04 PM3/7/18
to grpc.io
Hello,
I was working on a grpc server based project, I have a proto which has updated through different versions. As I was testing my server from different aspect. It was evident that when a call is made on server from a older version of proto, server throws error:

Mar 08, 2018 12:57:49 AM io.grpc.internal.SerializingExecutor run
SEVERE: Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1@4e158ee6
io.grpc.StatusRuntimeException: INTERNAL: Invalid protobuf byte sequence
at io.grpc.Status.asRuntimeException(Status.java:517)
at io.grpc.protobuf.lite.ProtoLiteUtils$2.parse(ProtoLiteUtils.java:165)
at io.grpc.protobuf.lite.ProtoLiteUtils$2.parse(ProtoLiteUtils.java:79)
at io.grpc.MethodDescriptor.parseRequest(MethodDescriptor.java:280)
at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.messagesAvailable(ServerCallImpl.java:252)
at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1.runInContext(ServerImpl.java:576)
at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:102)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
at com.google.protobuf.InvalidProtocolBufferException.invalidEndTag(InvalidProtocolBufferException.java:106)
at com.google.protobuf.CodedInputStream$ArrayDecoder.checkLastTagWas(CodedInputStream.java:559)
at com.google.protobuf.CodedInputStream$ArrayDecoder.readMessage(CodedInputStream.java:817)
at com.mediaiq.caps.platform.Event.<init>(Event.java:57)
at com.mediaiq.caps.platform.Event.<init>(Event.java:9)
at com.mediaiq.caps.platform.Event$1.parsePartialFrom(Event.java:849)
at com.mediaiq.caps.platform.Event$1.parsePartialFrom(Event.java:844)
at com.google.protobuf.CodedInputStream$ArrayDecoder.readMessage(CodedInputStream.java:816)
at com.mediaiq.caps.platform.PublishRequest.<init>(PublishRequest.java:57)
at com.mediaiq.caps.platform.PublishRequest.<init>(PublishRequest.java:9)
at com.mediaiq.caps.platform.PublishRequest$1.parsePartialFrom(PublishRequest.java:668)
at com.mediaiq.caps.platform.PublishRequest$1.parsePartialFrom(PublishRequest.java:663)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:91)
at com.google.protobuf.AbstractParser.parseFrom(AbstractParser.java:49)
at io.grpc.protobuf.lite.ProtoLiteUtils$2.parseFrom(ProtoLiteUtils.java:170)
at io.grpc.protobuf.lite.ProtoLiteUtils$2.parse(ProtoLiteUtils.java:162)
... 9 more

 While the client gets error
io.grpc.StatusRuntimeException: UNKNOWN

I want the client side error to be more descriptive as why the call failed and what proto to use .I tried interceptor for catching the error, but the error does not get catch by interceptor. Is there any way to catch this error and modify the error for proper error handling.

PS. The Sample two proto verions are
Version 1.0:
service EchoService {
rpc Echo(SimpleMessage) returns (SimpleMessage) {}
}

message SimpleMessage {
string id = 1;
}

Version 2.0:
service EchoService {
rpc Echo(SimpleMessage) returns (SimpleMessage) {}
}

message SimpleMessage {
int64 id = 1;
}


Carl Mastrangelo

unread,
Mar 9, 2018, 1:57:38 PM3/9/18
to grpc.io
The error you see is correct.   In proto, you can't reuse field numbers or modify their type.   You'll need to use field id "2" instead.   Generally, you'll need to set both fields until all the old clients have been upgraded, and then remove field "1".
Reply all
Reply to author
Forward
0 new messages