gaeutilities icon indicating copy to clipboard operation
gaeutilities copied to clipboard

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

Open shehabic-work opened this issue 13 years ago • 8 comments

Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 634, in __call__
    handler.get(*groups)
  File ......../generate_session.py", line 14, in get
    session = sessions.Session()
  File ........./appengine_utilities/sessions.py", line 562, in __init__
    self.session = _AppEngineUtilities_Session.get_session(self)
  File ......../appengine_utilities/sessions.py", line 142, in get_session
    ds_session = db.get(str(session_key))
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1422, in get
    keys, multiple = datastore.NormalizeAndTypeCheckKeys(keys)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 180, in NormalizeAndTypeCheckKeys
    keys = [_GetCompleteKeyOrError(key) for key in keys]
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 2339, in _GetCompleteKeyOrError
    key = Key(arg)
  File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore_types.py", 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 . . . .

shehabic-work avatar Apr 04 '11 09:04 shehabic-work

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.

joerussbowman avatar Apr 04 '11 10:04 joerussbowman

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-work avatar Apr 09 '11 12:04 shehabic-work

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

shehabic-work avatar Apr 09 '11 12:04 shehabic-work

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

shehabic-work avatar Apr 09 '11 13:04 shehabic-work

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.

joerussbowman avatar Apr 10 '11 03:04 joerussbowman

I think this is a problem that GAE is having recently. Here are some occurrences for it outside of the Session class - http://code.google.com/p/googleappengine/issues/detail?id=4663, http://groups.google.com/group/google-appengine-python/browse_thread/thread/b2da1aacc15a673d

natgordon avatar Apr 24 '11 21:04 natgordon

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 - http://code.google.com/p/googleappengine/issues/detail?id=4238

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.

joerussbowman avatar Apr 25 '11 14:04 joerussbowman

Google is looking for appid's of apps that are having this issue. Please comment in this issue http://code.google.com/p/googleappengine/issues/detail?id=4238 on the appengine project with the appid of your app.

joerussbowman avatar Aug 19 '11 15:08 joerussbowman