25

I keep getting the following stack trace and am not sure what it means.

Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
    at com.google.protobuf.InvalidProtocolBufferException.invalidEndTag(InvalidProtocolBufferException.java:73)
    at com.google.protobuf.CodedInputStream.checkLastTagWas(CodedInputStream.java:124)
    at com.google.protobuf.AbstractMessageLite$Builder.mergeFrom(AbstractMessageLite.java:189)
    at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:732)
    at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:238)
    at com.google.protobuf.AbstractMessageLite$Builder.mergeFrom(AbstractMessageLite.java:178)
    at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:724)
  • What does "Protocol message end-group tag did not match expected tag." mean?
  • What is a "message end-group tag"?
  • Is this documented somewhere?
Rylander
  • 19,449
  • 25
  • 93
  • 144

1 Answers1

25

Groups in protobuf are written as a start/end numeric pair - kinda like how <foo> needs a </foo>, but in a different format. Essentially it is complaining that it found a </bar> instead (just: the xml is only a metaphor). The details are in the encoding specification, but the long and short is that one of:

  • the data is inherently corrupt (either by damage of by a faulty encoder), or
  • the data is becoming corrupt while reading, or
  • the data is fine and you gave a faulty decoder

If I had to guess, the data has been damaged in transit - because that is so frighteningly common

Michael Kohne
  • 11,888
  • 3
  • 47
  • 79
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Would you guys please consider [this related question](http://stackoverflow.com/questions/29531899/how-to-write-a-valid-decoding-file-based-on-a-given-proto-reading-from-a-pb?noredirect=1#comment47219218_29531899) – smatthewenglish Apr 09 '15 at 08:18
  • Would you guys please consider this related question:https://stackoverflow.com/questions/71276445/kafka-consumer-net-protocol-message-end-group-tag-did-not-match-expected-tag – Ehsan Akbar Feb 27 '22 at 06:31