Repository navigation
Treat a session voter that no longer exists as logged out instead of 500ing - #564
Merged
Merged
Conversation
…500ing A voter removed from an election after logging in kept their voter id in the session, and get_voter() raised Voter.DoesNotExist on the next private election page. Look the voter up with filter().first() and drop the stale session entry so they're sent to the voter login page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QuQvnySS4szpAhhKDrzDVG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Error
GET /helios/elections/<uuid>/viewon a private election returned a 500:Frequency: 1 occurrence in the last 24h (2026-11-13 19:15 UTC), on helios-main. Low volume, but deterministic: anyone whose session holds the id of a voter that has since been deleted gets a 500 on every private-election page guarded by
election_viewuntil the session expires.Root cause
get_voter()trustsCURRENT_VOTER_IDin the session (set by password voter login) and doesVoter.objects.get(...). If the admin removed that voter, for example by deleting and re-uploading the voter list, the lookup raises.Fix
filter(...).first().CURRENT_VOTER_IDfrom the session and fall through to the usual user-based lookup. On a private election the voter is sent to the password voter login page like any logged-out visitor.Added
ElectionBlackboxTests.test_private_election_view_with_deleted_session_voter. It fails withVoter.DoesNotExistwithout the fix and passes with it.uv run python manage.py test helios(293 tests) andhelios_authboth pass locally.Datadog
service:helios-main "in get_voter"(orservice:helios-main "Voter matching query does not exist")Generated by Claude Code