Skip to content

Error when loading session from 1.11 on 1.12 #226

@kotofos

Description

@kotofos

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions