Skip to content

Normalize voter IDs and preserve punctuation in voting links - #1666

Open
jacksonloper wants to merge 6 commits into
mainfrom
fix/normalize-admin-voter-ids
Open

jacksonloper wants to merge 6 commits into
mainfrom
fix/normalize-admin-voter-ids

Conversation

@jacksonloper

@jacksonloper jacksonloper commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Admin-supplied voter IDs were stored verbatim even though voter lookup trims whitespace. Alice and Alice could bypass duplicate checks while identifying the same voter at login. IDs were also interpolated directly into URLs, so an ID such as Alice?# was interpreted as a query/fragment rather than a credential.

  • Trim IDs before filtering, validation, duplicate checks, and storage. Reject duplicates within an upload and compare against trimmed existing IDs. Blank cells retain missing-ID behavior: ignore otherwise-empty rows or generate an ID when other voter data is supplied.
  • Encode IDs at every voting-link and API-path construction site: copied admin links, invitation and custom email buttons, receipt update links, voter-roll lookup, and individual invitation requests. Preserve punctuation in stored IDs.
  • Reject newly supplied IDs that cannot round-trip through the current authentication flow: non-Latin-1 characters and controls (the cookie uses btoa/atob), dot-only path segments, and literal %2F sequences (case-insensitively, due to router decoding). Return explicit errors rather than rewriting credentials.
  • Document the rules. Case, leading zeros, and internal spaces remain significant. Existing records are not rewritten; the validation does not repair previously imported unsupported IDs.

Validation

  • 65 tests passed across controller normalization/validation, email-link generation, and existing ID, email, and clear-roll suites (jest --runInBand --silent). Includes encoded API lookup and authentication with punctuation-containing IDs. Silent mode suppresses existing event-queue logging after test completion.
  • Frontend and backend tsc --noEmit passed.
  • Seven representative IDs round-tripped through URL parsing, the installed React Router, and btoa/atob.
  • git diff --check passed.
  • ESLint could not run because the local dependency installation lacks eslint-plugin-security.

@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for bettervoting ready!

Name Link
🔨 Latest commit c762cc1
🔍 Latest deploy log https://app.netlify.com/projects/bettervoting/deploys/6af750d5c7f648a25b305d40
😎 Deploy Preview https://deploy-preview-1666--bettervoting.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Equal-Vote/bettervoting/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 0e8d196f-0964-4b06-ab0e-9149560edd70

📥 Commits

Reviewing files that changed from the base of the PR and between 41a1d05 and 82ff38f.

📒 Files selected for processing (2)
  • packages/backend/src/Controllers/Roll/addElectionRollController.test.ts
  • packages/backend/src/Controllers/Roll/addElectionRollController.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Voter IDs are now consistently trimmed before validation and storage.
    • Duplicate IDs within an upload are rejected.
    • Existing voter IDs are detected after trimming.
    • Blank rows are ignored, while incomplete rows receive unique generated IDs.
    • Email invitations now tolerate blank voter ID fields while still rejecting supplied IDs when unsupported.

Walkthrough

addElectionRoll now trims submitted voter IDs, rejects duplicate non-empty IDs, and compares normalized IDs with existing rolls. It supports synchronous and asynchronous generated IDs. New tests cover whitespace handling, duplicate detection, case sensitivity, blank rows, generated IDs, and invitation-specific rules.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 82ff3

The controller now normalizes voter IDs before validation and storage, with coverage for the affected upload behaviors. No actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies voter ID normalization, which is the primary change. It also references punctuation preservation in voting links, a related behavior described in the pull request.
Description check ✅ Passed The description is detailed and explains the changes, validation results, limitations, and unsupported ID rules. The frontend-only screenshots section is not required for this backend change. The Rela…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

Comment @coderabbitai help to get the list of available commands.

@jacksonloper jacksonloper changed the title Normalize admin-supplied voter IDs before adding rolls Normalize voter IDs and preserve punctuation in voting links Sep 22, 2026
jacksonloper and others added 4 commits November 4, 2026 13:29
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Resolve conflicts by taking main's removal of the invite email path
(Invites template, useSendInvite).
Invites() no longer exists, and main now rejects precinct values unless
voter groups are enabled, so enable them in the roll controller test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ArendPeter
ArendPeter requested review from mikefranze and removed request for ArendPeter November 14, 2026 04:58

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant