You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(api): finalize_login 500: KeyError when flask session key is absent (CampusSessions.Session.finalize) #59
/finalize_login on campus-profile (development) returned Internal Server Error with:
File "campus_python/auth/v1/__init__.py", line 167, in finalize
target = self.sessions[auth_session.id].finalize()
File "campus_python/auth/v1/sessions.py", line 106, in finalize
del flask.session[cast(CampusSessions, self.parent)._session_key]
KeyError: '_session_id'
Root cause
CampusSessions.Session.finalize() assumes the flask session key is always present and uses a bare del (campus_python/auth/v1/sessions.py:106). The key can legitimately be absent — e.g. the browser's session cookie is lost/stripped between /login and the OAuth callback (observed on mobile Safari), or a replayed callback after push_context already cleaned the stale key.
Related smell in the same class (campus_python/auth/v1/sessions.py):
changed the title [-]finalize_login 500: KeyError when flask session key is absent (CampusSessions.Session.finalize)[/-][+]fix(api): finalize_login 500: KeyError when flask session key is absent (CampusSessions.Session.finalize)[/+]on Oct 3, 2026
Activity
[-]finalize_login 500: KeyError when flask session key is absent (CampusSessions.Session.finalize)[/-][+]fix(api): finalize_login 500: KeyError when flask session key is absent (CampusSessions.Session.finalize)[/+]