Key raises ProtocolBufferDecodeError for some invalid serialized keys
See original GitHub issueWhat steps will reproduce the problem?
from google.appengine.ext.ndb import model
model.Key(urlsafe='foo')
What is the expected output?
ValueError?
What do you see instead?
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/key.py", line 209, in __new__
self.__reference = _ConstructReference(cls, **kwargs)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 93, in positional_wrapper
return wrapped(*args, **kwds)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/key.py", line 599, in _ConstructReference
reference = _ReferenceFromSerialized(serialized)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/ndb/key.py", line 731, in _ReferenceFromSerialized
return entity_pb.Reference(serialized)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/proto1/internal/cpp_message.py", line 555, in Init
self.MergeFromString(contents)
File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/proto1/internal/cpp_message.py", line 633, in MergeFromString
raise ProtocolBufferDecodeError('Unable to merge from string.')
ProtocolBufferDecodeError: Unable to merge from string.
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/ndb/key.py", line 209, in __new__
self.__reference = _ConstructReference(cls, **kwargs)
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 93, in positional_wrapper
return wrapped(*args, **kwds)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/ndb/key.py", line 599, in _ConstructReference
reference = _ReferenceFromSerialized(serialized)
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/ndb/key.py", line 731, in _ReferenceFromSerialized
return entity_pb.Reference(serialized)
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/entity_pb.py", line 1774, in __init__
if contents is not None: self.MergeFromString(contents)
File "/base/python_runtime/python_lib/versions/1/google/net/proto/ProtocolBuffer.py", line 85, in MergeFromString
self.MergePartialFromString(s)
File "/base/python_runtime/python_lib/versions/1/google/net/proto/ProtocolBuffer.py", line 92, in MergePartialFromString
self._CMergeFromString(s)
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/entity_pb.py", line 1819, in _CMergeFromString
_net_proto___parse__python.MergeFromString(self, 'storage_onestore_v3.Reference', s)
ProtocolBufferDecodeError: Corrupted message: invalid wire type 6 encountered
for tag 15
What version of the product are you using?
NDB 0.9.3
App Engine production 1.6.1
Original issue reported on code.google.com by sa...@google.com
on 22 Jan 2012 at 11:11
Issue Analytics
- State:
- Created 8 years ago
- Reactions:6
- Comments:10
Top Results From Across the Web
Key raises ProtocolBufferDecodeError for some invalid ...
Unit testing works fine catching from google.net.proto.ProtocolBuffer import ProtocolBufferDecodeError, but in production does not. File "/base/ ...
Read more >ProtocolBufferDecodeError: truncated when using ndb.Key
If this is the case, then the workaround would be to just use ID of the entity (or entities in case of parent...
Read more >google.appengine.datastore.datastore_query - Google Cloud
BadPropertyError: if the property name is invalid. datastore_errors. ... property_names): """Extracts key values from the given entity.
Read more >google/appengine/ext/ndb/context.py - Google Git
raise ValueError('Cannot specify %s and %s at the same time' %. (key, translation)) ... Key gets the singleton Context instance and invokes Context.get....
Read more >google.cloud.ndb.key — ndb documentation
Key ` for Google Cloud Datastore. .. testsetup:: * from google.cloud import ndb ... Raises: TypeError: If none of ``reference``, ``serialized``, ``urlsafe``, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Original comment by
herr.ka...@gmail.com
on 24 Sep 2013 at 10:36Run into this issue while refactoring code.
This bit of code catches this type of exception:
Example: