Stack Exchange
Unexpected Group Tag error while deserializing protobuf file
While deserializing onnx binary I am getting following error:
Traceback (most recent call last):
 from model.ParseFromString(f.read())
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/message.py", line 185, in ParseFromString
 self.MergeFromString(serialized)
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/internal/python_message.py", line 1063, in MergeFromString
 if self._InternalParse(serialized, 0, length) != length:
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/internal/python_message.py", line 1099, in InternalParse
 pos = field_decoder(buffer, new_pos, end, self, field_dict)
 File "~/protobuf-3.3.0-py2.7.egg/google/protobuf/internal/decoder.py", line 615, in DecodeRepeatedField
 raise _DecodeError('Unexpected end-group tag.')
 google.protobuf.message.DecodeError: Unexpected end-group tag.

I am using protobuf version 3.3.0. I am using ParseFromString function which gives the error.
Can anybody please help me on how to handle this error?

does your payload validate cleanly here: https://protogen.marcgravell.com/decode ? if that site also says you have an unexpected end-group tag, then: you probably have an unexpected end-group tag - which means: your data is corrupt. So: where did the data come from? has it been treated as text at some point? (protobuf is not text; treating it as text will corrupt it) can you perhaps post the hex or base-64 of the payload here? does your schema even use groups? note: another common possible cause of corruption is overwriting a file with less data without truncating it (trailing garbage).

I am using https://github.com/onnx/models/blob/master/vision/body_analysis/emotion_ferplus/model/emotion-ferplus-2.onnx file

I'm not familiar with onnx - is that the raw protobuf binary payload?

I am using import proto3_pb2
f = open(sys.argv[1],"rb")
model = proto3_pb2.ModelProto()
model.ParseFromString(f.read())
f.close()
graph = model.graph
print(graph.node) . This reads the onnx binary

I tried with protobuf 3.5.2 and it was working. Is there a bug in this version. If yes, if there a way I can solve without switching to this version

I'm going to hazard a guess at "no, you'll need to use the version that works"

@MarcGravell can u give it a try with protobuf 3.3.0. If it works at your end.
