Conversation
…nything
In an ID-list election the voter-ID field renders in its error state with the
helper text "Invalid Voter ID" from the moment the page loads, before the voter
has typed a character. First impression of the voting flow: you got it wrong.
Cause: VoterAuth.tsx tests voterAuth?.required === "Voter ID Required", but the
backend (voterRollUtils.ts getMissingAuthData) returns "Voter ID Required for
closed elections". The comparison never matches, so missingVoterID is always
false and the error branch (!missingVoterID && !isAuthorized) is true on first
paint.
Fixed on the frontend side by comparing against the string the backend actually
sends. The sibling check ("Email Validation Required") already matches its
backend string exactly, which is how the drift went unnoticed -- one of the two
worked.
With the comparison fixed, the field starts in its neutral state and the error
appears only after a submitted ID actually fails.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
✅ Deploy Preview for bettervoting ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe voter authentication check now identifies the message Poem
Merge Risk: ⚪ Minimal · up to This localized frontend fix changes the voter-ID field from an incorrect error state on initial load to the intended neutral state until an invalid ID is submitted. No actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Description
In an ID-list election, the voter-ID field renders in its error state with "Invalid Voter ID" from the moment the page loads — before the voter has typed a character.
Cause:
VoterAuth.tsx:47testsvoterAuth?.required === "Voter ID Required", but the backend (voterRollUtils.tsgetMissingAuthData) returns"Voter ID Required for closed elections". The comparison never matches, somissingVoterIDis alwaysfalse, and the error branch(!missingVoterID && !isAuthorized)is true on first paint.Fix: compare against the string the backend actually sends. One line, frontend side — the backend string may appear in logs, so the compare is the safer end to change. The sibling check (
"Email Validation Required") already matches its backend string exactly, which is how this drifted unnoticed: one of the two worked.After the fix the field starts neutral, and the error appears only after a submitted ID actually fails.
Longer-term these magic-string comparisons would be safer as shared constants or an enum on the auth response — happy to do that as a follow-up if wanted; this PR is the minimal behaviour fix.
Screenshots / Videos (frontend only)
Behaviour fix visible in any ID-list election: before, the field is red with "Invalid Voter ID" on load; after, it is neutral until a wrong ID is submitted.
Related Issues
Found while writing the voter troubleshooting help page (#1550, indexed in #1556).