Repository navigation
Conversation
A voter upload row for an auth-system user (e.g. GitHub) only checked for an existing voter linked to the same user. If a voter of another type (a password voter, or a user from another auth system with the same username) already held that login ID, the insert hit the (election, voter_login_id) unique constraint and the voter_file_process task failed partway, leaving the list half-loaded. Treat such rows as already present and count them as skipped, like the password branch already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QuQvo1ztjyRJhw8Pg5RUHw
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 2 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
Owner
Author
|
let's not do this. If we get this error again we'll consider it. |
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
The
helios.tasks.voter_file_processbackground task fails with:Frequency: 2 failed uploads in the last 14 days (Nov 11 and Nov 22), both on this same frame. These are the only
voter_file_processfailures in that window.Root cause
In
VoterFile.process(), a row for an auth-system voter (GitHub, Google, etc.) only checks for an existing voter linked to the sameUser(get_by_election_and_user).register_user_in_electionthen setsvoter_login_id = user.user_id. If another voter in the election already has that login ID, the insert hits the(election, voter_login_id)unique constraint. That other voter could be a password voter with the same ID, or a user from a different auth system with the same username. In the production failure, the new row was an auth-system user with no email on file.Voters are created one at a time in shuffled order with no surrounding transaction. So when the task fails, the election is left with a random subset of the file loaded, and
processing_finished_atis never set.Fix
Before registering, also check
Voter.get_by_election_and_voter_id(election, user.user_id), which the password branch already does. A row whose login ID is already taken is treated as already present and counted innum_skipped, like other duplicate rows.Tests
ElectionModelTests.test_add_voters_file_skips_login_id_taken_by_another_voter_type. It loads a password voter, then uploads a file with a GitHub row using the same ID plus one new GitHub voter. Without the fix the test fails with the sameIntegrityError; with the fix it passes.uv run python manage.py test: 338 tests, OK (1 skipped).Datadog
Generated by Claude Code