Hi,
I am getting this "Truncated string." error quite a lot during my decoding
of string field.
The problem is the end of the buffer, calculations say size is 32 but at
the end of the string, it only has to look for 32877.
The position where this error occurs is position 90 (in my example) on the
buffer which happens to be a string. The size that I see in return (in
protobuf code) is 32 which means the code is probably converting it into
ascii instead of regular string. As a side note this problem happens when I
am using RabbitMQ to receive the data but not when I serialize and
deserialize the data within the same code. Also, even after I receive, the
data is exactly the same - with the same hex codes and length of the string
itself but it just refuses to work. I have been struggling with this since
a while now and will appreciate any further input as I want to use protobuf
for my serialization.
Here's the log around the issue.
File ".../python2.7/site-packages/google/protobuf/internal/decoder.py",
line 521, in DecodeField
raise _DecodeError('----------- Truncated string. buffer[] = {} \n\t
new_pos={}; end={}; size={}; pos={}; \n Locals={}'.format(buffer[pos:],
new_pos, end, size, pos, locals()))
DecodeError: ----------- Truncated string. buffer[] = 32877
new_pos=123; end=96; size=32; pos=91;
Locals={'key': <google.protobuf.descriptor.FieldDescriptor object at
0x7fdac9600e10>, 'end': 96, 'field_dict': {<google.protobuf.descriptor.
FieldDescriptor object at 0x7fdac9600c90>: <core_pb2.InstrumentId object at
0x7fdac4494140>, <google.protobuf.descriptor.FieldDescriptor object at
0x7fdac9600d50>: <mkt_pb2.MarketInfoL1 object at 0x7fdac44942a8>, <google.
protobuf.descriptor.FieldDescriptor object at 0x7fdac9600cd0>: <core_pb2.
DateTime object at 0x7fdac4494230>, <google.protobuf.descriptor.
FieldDescriptor object at 0x7fdac9600d10>: 1}, 'new_pos': 123L, 'buffer':
'\n\x1a\x08\x08\x12\x16FUTURE|XSES|NKZ15|1512\x12\x11\x08\xe6\xf5\xcd\t\x12\n\x08\xbc\x98\x05\x10\xb8\x98\x88\x96\x01\x18\x01"&\x08\x93\xc6\r\x10\x01\x1a\x1a\x08\x08\x12\x16FUTURE|XSES|NKZ15|15122\x02\x10\n:
32877', 'pos': 91L, 'local_DecodeVarint': <function DecodeVarint at
0x7fdac980b0c8>, 'message': <box_pb2.RawTick object at 0x7fdac4492de8>,
'_ConvertToUnicode': <function _ConvertToUnicode at 0x7fdac970ecf8>, 'size':
32L}
I modified the *google/protobuf/internal/decoder.py* file to create that
log so that I can see what's happening but I could only go so far.
515 def DecodeField(buffer, pos, end, message, field_dict):
516 print('++++++++++++++Truncated string. buffer[] = {} \n\t end={};
pos={}; \n Locals={}'.format(buffer, end, pos, locals()))
517 (size, pos) = local_DecodeVarint(buffer, pos)
518 # size = 1
519 new_pos = pos + size
520 if new_pos > end:
521 raise _DecodeError('----------- Truncated string. buffer[] =
{} \n\t new_pos={}; end={}; size={}; pos={}; \n Locals={}'.format(buffer[pos
:], new_pos, end, size, pos, locals()))
522 field_dict[key] = _ConvertToUnicode(buffer[pos:new_pos])
523 return new_pos
524 return DecodeField
Thank you for your time.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.