I use the following code to get an urlsafe key based entity:
q_key = ndb.Key(urlsafe=key) q = q_key.get() return q
But if such an object with the specified urlsafe key does not exist, it returns ProtocolBufferDecodeError: Unable to merge from string in the first line when I expect q to be None . Is there any other correct way to handle this case other than a ProtocolBufferDecodeError exception?
source share