Protobuf Unexpected end-group tag

5,068 views
Skip to first unread message

Wei Chiang Lim

unread,
Mar 14, 2016, 1:12:59 PM3/14/16
to Protocol Buffers
Hi all

I'm trying parse protobuf messages subscribed from a zeromq feed using Python. Intermittently when I parse the message string, my script crashes with the following error

  File "ale-feed-location-reader.py", line 37, in <module>

    aleEvent.ParseFromString(recvMsg)

  File "/usr/lib/python2.7/dist-packages/google/protobuf/message.py", line 182, in ParseFromString

    self.MergeFromString(serialized)

  File "/usr/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 798, in MergeFromString

    raise message_mod.DecodeError('Unexpected end-group tag.')

google.protobuf.message.DecodeError: Unexpected end-group tag.


My script looks like the following, seems fairly simple enough. Has anyone seen this before, and how would you fix this? My guess is that it is not any corruption on the message from the zmq server, as a vendor provided c++ compiled program is able to parse the messages without any problem.

----------snip----------
# Socket to talk to server
context = zmq.Context()
clientSock = context.socket(zmq.SUB)
clientSock.connect ("tcp://%s:%s" % (serverAddr, serverPort))
print('Connected to {0} at port {1}'.format(serverAddr, serverPort))

topicfilter = ""
clientSock.setsockopt(zmq.SUBSCRIBE, topicfilter)

while(1):
# Receive Message
recvMsg = ''.join(clientSock.recv_multipart())
# Parse Message
aleEvent = schema_pb2.nb_event()
aleEvent.ParseFromString(recvMsg)
if aleEvent.IsInitialized():
time = datetime.datetime.fromtimestamp(aleEvent.timestamp)
----------snip----------

Thanks for any insight!

Jie Luo

unread,
Mar 14, 2016, 1:50:39 PM3/14/16
to Wei Chiang Lim, Protocol Buffers
We are going to change the c++ implementation to the same behavior
with pure python which will raise 'Unexpected end-group tag.' too.
Please see http://b/27494216
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to protobuf+u...@googlegroups.com.
> To post to this group, send email to prot...@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.

Lim Wei Chiang

unread,
Mar 14, 2016, 9:41:26 PM3/14/16
to Jie Luo, Protocol Buffers
Hi Jie Luo,

What does the error denote, what should I be checking for?

The link you sent has a typo I believe.

Thanks for any advice.


--
Sent from a mobile phone

Jie Luo

unread,
Mar 15, 2016, 3:42:53 PM3/15/16
to Lim Wei Chiang, Protocol Buffers
It checks the end group tag 4 which should be deprecated.

https://developers.google.com/protocol-buffers/docs/encoding#structure

vladimir...@teamaol.com

unread,
Jun 10, 2016, 3:04:36 PM6/10/16
to Protocol Buffers, weic...@gmail.com
Hi Jie Luo,

Could you explain a little more which C++ code you are talking about - one that creates message
(that is later parsed in Python) or something else?

If so, could you provide your changes?

Thanks,
Vladimir
Thanks for any advice.

> To post to this group, send email to prot...@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.

Jie Luo

unread,
Jun 13, 2016, 1:35:48 PM6/13/16
to vladimir...@teamaol.com, Protocol Buffers, Wei Chiang Lim
I am talking about C++ implementation for python. We should add more checks for MergeFromString() in message.cc. I have a change in internal code, however it was blocked by another team because they have a lot of  corrupted data which haven't fix yet

Thanks for any advice.

> To post to this group, send email to prot...@googlegroups.com.
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.


--
Sent from a mobile phone

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages