Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when loading session from 1.11 on 1.12 #226

Open
kotofos opened this issue Mar 13, 2023 · 0 comments
Open

Error when loading session from 1.11 on 1.12 #226

kotofos opened this issue Mar 13, 2023 · 0 comments

Comments

@kotofos
Copy link
Contributor

kotofos commented Mar 13, 2023

Error when loading session from 1.11 on 1.12
Looks like a problem was introduced in the code handling deserialization of saved sessions. If the previous session was not serialized.

#122

8949516

Options:

  • mark as invalid and delete with invalidate_corrupt
  • add serializer=None
  • fallback for loading non serialized sessions
  • Mention it in docs

Reproduce

  • Install 1.11
  • Create session
  • Install 1.12
  • restart app
  • get session

Tested on
pyramid==1.10.8
pyramid-beaker==0.8

  File "/home/kotofos/Documents/slashdb/slashdb_venv39/lib/python3.9/site-packages/pyramid/authentication.py", line 1151, in unauthenticated_userid
    return request.session.get(self.userid_key)
  File "/home/kotofos/Documents/slashdb/slashdb_venv39/lib/python3.9/site-packages/beaker/session.py", line 789, in __getattr__
    return getattr(self._session(), attr)
  File "/home/kotofos/Documents/slashdb/slashdb_venv39/lib/python3.9/site-packages/beaker/session.py", line 785, in _session
    self.__dict__['_sess'] = session_cls(req, **params)
  File "/home/kotofos/Documents/slashdb/slashdb_venv39/lib/python3.9/site-packages/beaker/session.py", line 227, in __init__
    self.load()
  File "/home/kotofos/Documents/slashdb/slashdb_venv39/lib/python3.9/site-packages/beaker/session.py", line 415, in load
    session_data = self._decrypt_data(session_data)
  File "/home/kotofos/Documents/slashdb/slashdb_venv39/lib/python3.9/site-packages/beaker/session.py", line 372, in _decrypt_data
    data = b64decode(session_data)
  File "/home/kotofos/Documents/slashdb/slashdb_venv39/lib/python3.9/site-packages/beaker/_compat.py", line 37, in b64decode
    return _b64decode(b.encode('ascii'))
AttributeError: 'dict' object has no attribute 'encode'

Workaround

Delete sessions from filesystem or use invalidate_corrupt

eshizhan added a commit to eshizhan/beaker that referenced this issue Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant