Skip to content

raise unexpected exception while property value is [] #403

@lucemia

Description

@lucemia

the following sample code

entity = Entity(dataset, 'test')
entity['a'] = []
entity.save()

will raise exception

File "/usr/local/lib/python2.7/dist-packages/gcloud-0.3.0-py2.7.egg/gcloud/datastore/entity.py", line 244, in save
    exclude_from_indexes=self.exclude_from_indexes())
  File "/usr/local/lib/python2.7/dist-packages/gcloud-0.3.0-py2.7.egg/gcloud/datastore/connection.py", line 429, in save_entity
    result = self.commit(dataset_id, mutation)
  File "/usr/local/lib/python2.7/dist-packages/gcloud-0.3.0-py2.7.egg/gcloud/datastore/connection.py", line 329, in commit
    datastore_pb.CommitResponse)
  File "/usr/local/lib/python2.7/dist-packages/gcloud-0.3.0-py2.7.egg/gcloud/datastore/connection.py", line 81, in _rpc
    data=request_pb.SerializeToString())
  File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 813, in SerializeToString
    self.DESCRIPTOR.full_name, ','.join(self.FindInitializationErrors())))
EncodeError: Message api.services.datastore.CommitRequest is missing required fields: mutation.upsert[0].property[0].value

It (protobuf) makes no distinction between an empty list and a null list.

http://stackoverflow.com/questions/2378666/protobuf-net-serializing-an-empty-list
it looks like a property with empty list should be skip entirely

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.api: datastoreIssues related to the Datastore API.triage meI really want to be triaged.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions