Sometime session key is generating with Strange Characters . . that isn't accepted in DB #28

shehabic opened this Issue Apr 4, 2011 · 8 comments


None yet

3 participants

shehabic commented Apr 4, 2011
Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/", line 634, in __call__
  File ......../", line 14, in get
    session = sessions.Session()
  File ........./appengine_utilities/", line 562, in __init__
    self.session = _AppEngineUtilities_Session.get_session(self)
  File ......../appengine_utilities/", line 142, in get_session
    ds_session = db.get(str(session_key))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/", line 1422, in get
    keys, multiple = datastore.NormalizeAndTypeCheckKeys(keys)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/", line 180, in NormalizeAndTypeCheckKeys
    keys = [_GetCompleteKeyOrError(key) for key in keys]
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/", line 2339, in _GetCompleteKeyOrError
    key = Key(arg)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/", line 364, in __init__
    raise datastore_errors.BadKeyError('Invalid string key %s.' % encoded)
BadKeyError: Invalid string key ag5tZWdhcGx1Z2luc2FwcHIjCxIbX0FwcEVuZ2luZVV0aWxpdGllc19TZXNzaW9uGKC=.

for some reason sometime the key isn't string . . . .


Can you grab the latest version from the repo and see if it's still a problem. I thought I fixed this a while ago.

shehabic commented Apr 9, 2011

I'll get the latest version . . the problem is that there aren't any specific steps to reproduce the problem it just happens by luck because of the random key generation . .

shehabic commented Apr 9, 2011

The problem is still there I already had the latest version . .

shehabic commented Apr 9, 2011

I don't see any invalid characters is it because the key is too long ?


Not sure why this is happening, the key is the key generated by the datastore. It does seem odd that your key has =. at the end, I don't recall seeing anything other than alphanumeric characters in the past.

Hitting the gaeutilities demo page and deleting the key over and over I couldn't reproduce the problem. Though honestly the demo seems a little slow. Not sure if changes since the last time I wrote code for this have affected the performance negatively.

Unfortunately I'm not developing on Appengine any more, so I'm not sure how much time I'd be able to find to troubleshoot this. Pretty much at this point my primary maintenance for this project is to review and apply any pull requests people might offer. I did plan on a major rewrite to assist with performance, but I've never had a chance to get to finishing it.


I think this is a problem that GAE is having recently. Here are some occurrences for it outside of the Session class -,


Guys, I thought this looked familiar. I never made changes to manage this because it's not a change I can make unless I rewrite the identifier to not use the datastore id at all. That's a possibility, but I don't have time right now to address this. As I've said before I am looking for volunteers to help with this project as I'm not using it any more.

However, I've been doing my best to keep up with at least bug fixes, and in December of 2010 I made the choice to not rewrite, I filed an issue with GAE to ask them to fix the problem on their end. As shown above, this issue is affecting more than just gaeutilities.

Here's the issue, which is in status Acknowledged state right now in Google Appengine Issue Tracker -

My suggestion would be to star that issue. I will leave this issue open until it's been resolved though for tracking and information purposes.


Google is looking for appid's of apps that are having this issue. Please comment in this issue on the appengine project with the appid of your app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment