Broken Datastore

2 views
Skip to first unread message

keving

unread,
May 18, 2008, 9:36:08 AM5/18/08
to Google App Engine
I have a datastore entity with a im field, like so:

class Player(db.Model):
user = db.UserProperty()
nick_name = db.StringProperty()
im = db.IMProperty()
.....

Someone has managed to store a player with a bogus IM address (I'm not
sure how I am supposed to validate those :(). But now I can't delete
it! Whenever I fetch this record my app crashes:

Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/
__init__.py", line 499, in __call__
handler.get(*groups)
File "/base/data/home/apps/zeno/1.6/standings.py", line 145, in get
results = players.fetch(20)
File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 1299, in fetch
raw = self._get_query().Get(offset+limit)
File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 889, in Get
return self._Run(count)._Next(count)
File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 1182, in _Next
ret = [Entity._FromPb(r) for r in result.result_list()]
File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 525, in _FromPb
value = datastore_types.FromPropertyPb(prop)
File "/base/python_lib/versions/1/google/appengine/api/
datastore_types.py", line 1099, in FromPropertyPb
value = _PROPERTY_CONVERSIONS[pb.meaning()](value)
File "/base/python_lib/versions/1/google/appengine/api/
datastore_types.py", line 672, in __init__
str(protocol))
BadValueError: Expected string of format "protocol address"; received
http://talk.google.com/ his IM account

If I go to my application's admin section and hit Data Viewer, I get

Server Error

A server error has occured.

which I assume s related. Is there any way I can clear my data?

Thanks

Duncan

unread,
May 18, 2008, 10:30:48 AM5/18/08
to Google App Engine
On May 18, 2:36 pm, keving <kevin.gl...@gmail.com> wrote:
> I have a datastore entity with a im field, like so:
>
> class Player(db.Model):
> user = db.UserProperty()
> nick_name = db.StringProperty()
> im = db.IMProperty()
> .....
>
> Someone has managed to store a player with a bogus IM address (I'm not
> sure how I am supposed to validate those :(). But now I can't delete
> it! Whenever I fetch this record my app crashes:
>
Try uploading a different version of your app (i.e. edit the version
string) and the model changed to say:

im=db.StringProperty()

then delete the offending record using that version.

keving

unread,
May 18, 2008, 11:29:49 AM5/18/08
to Google App Engine
Thanks, I hadn't thought of incrementing the version number, but
unfortunately:

BadValueError: Property im must be a str or unicode instance, not a
IM

Duncan

unread,
May 18, 2008, 12:09:56 PM5/18/08
to Google App Engine
Ok, suggestion number 2. Put the property back to being an IM property
but add the following code to the top of your code:

---------------------------------------------------------
from google.appengine.api.datastore_types import IM

def IM_init(self, protocol, address=None):
if address is None:
try:
split = protocol.split(' ', 1)
protocol, address = split
except (AttributeError, ValueError):
raise datastore_errors.BadValueError(
'Expected string of format "protocol address"; received %s'
%
str(protocol))

ValidateString(address, 'address')
if protocol not in self.PROTOCOLS:
Link(protocol)

self.address = address
self.protocol = protocol

setattr(IM, '__init__', IM_init)
---------------------------------------------------------
i.e. make a copy of the method which throws the exception but modified
so that it won't complain (I added a second parameter to the split
call so it only splits on the first space character not on all of
them) and then monkey patch it back into the IM class.

I *think* that ought to do it, and if it does you could post a bug
report: if they are going to expect only 2 strings after the split
they ought to either limit the split of check for spaces before
storing the value.

keving

unread,
May 18, 2008, 3:51:44 PM5/18/08
to Google App Engine
On May 18, 11:09 am, Duncan <kupu...@googlemail.com> wrote:
> On May 18, 4:29 pm, keving <kevin.gl...@gmail.com> wrote:
>
>
>
> > On May 18, 9:30 am, Duncan <kupu...@googlemail.com> wrote:
>
> > > On May 18, 2:36 pm, keving <kevin.gl...@gmail.com> wrote:> I have a datastore entity with a im field, like so:
>
> > > > class Player(db.Model):
> > > > user = db.UserProperty()
> > > > nick_name = db.StringProperty()
> > > > im = db.IMProperty()
> > > > .....
>
> > > > Someone has managed to store a player with a bogus IM address (I'm not
> > > > sure how I am supposed to validate those :(). But now I can't delete
> > > > it! Whenever I fetch this record my app crashes:
>
...
Thanks! That did it. Although I had to comment out this section:

> ValidateString(address, 'address')
> if protocol not in self.PROTOCOLS:
> Link(protocol)

But I only needed to get the entity loaded so that I could delete it.
I will post a bug report, and for now ban spaces!

Kevin

Reply all
Reply to author
Forward
0 new messages