user714852 user714852 - 1 year ago 68
Python Question

Appengine throwing BadRequestError: The is the empty string

I have an application that has worked successfully in the past. Today however, it's started throwing an error when I try write to datastore. For example, I'm creating a new entity of this model

class EventInstallment(ndb.Model):
somekey = ndb.KeyProperty()
somename = ndb.StringProperty(default = "")
start_date = ndb.DateTimeProperty()
notes = ndb.StringProperty("")

moderator_approved = ndb.BooleanProperty(default = True)
added_by = ndb.KeyProperty()

created = ndb.DateTimeProperty(auto_now_add = True)

using this code

ins = somemodel()
ins.somename = "26-september-2016"
ins.somekey = the_key
ins.start_date =

and this exception gets thrown.

Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/admin/", line 363, in post
exec(compiled_code, globals())
File "<string>", line 8, in <module>
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/", line 3451, in _put
return self._put_async(**ctx_options).get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/", line 383, in get_result
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/", line 427, in _help_tasklet_along
value = gen.throw(exc.__class__, exc, tb)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/", line 824, in put
key = yield self._put_batcher.add(entity, options)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/", line 427, in _help_tasklet_along
value = gen.throw(exc.__class__, exc, tb)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/", line 358, in _put_tasklet
keys = yield self._conn.async_put(options, datastore_entities)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/ext/ndb/", line 513, in _on_rpc_completion
result = rpc.get_result()
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/", line 613, in get_result
return self.__get_result_hook(self)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/datastore/", line 1881, in __put_hook
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/datastore/", line 1373, in check_rpc_success
raise _ToDatastoreError(err)
BadRequestError: The is the empty string.

Any idea what this issue might be? It looks like a change in GAE ndb - as it worked as recently as 1 month ago...

Answer Source

Shouldn't notes = ndb.StringProperty("") be: notes = ndb.StringProperty(default = "") ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download