fix: match paid player in token flow despite name mismatch #42
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api!42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/token-player-dedup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Changes
src/basketball_api/routes/register.py: When name match fails in token flow, fall back to matching the parent's single paid player. Updates name to form value. Siblings (multiple paid players) still use name matching.Test Plan
Review Checklist
Related
plan-2026-03-08-tryout-prep— Phase 3bPR #42 Review
BLOCKERS
None. The fix is logically correct and well-scoped.
NITS
No automated test for the new fallback path. The existing
test_register.pycovers the token pre-fill flow and the name-match dedup, but there is no test for the specific scenario this PR fixes: token flow where the form player name differs from the Stripe player name, with a single paid player under the parent. A test like this would pin down the fix:/registerwithtoken=...andplayer_name="Creed".Not blocking given the time-sensitive nature, but this should be backfilled.
Issue reference mismatch. The PR body says "Closes #20" but issue #20 is "Phase 3b email blast," not a player dedup bug. There does not appear to be a dedicated Forgejo issue for this dedup bug. Consider either creating one or correcting the reference so the issue link is accurate. This matters for audit trail.
Branch naming. Branch is
fix/token-player-deduprather than the SOP convention of naming after an issue number (e.g.,issue-XX/...). Related to point 2 above -- no dedicated issue exists to name it after.SOP COMPLIANCE
fix/token-player-dedup, no corresponding issue numberplan-2026-03-08-tryout-prepreferencedroutes/register.py, no credentialsfix: match paid player in token flow despite name mismatchCode Analysis
Correctness of the fallback logic (
register.pylines 809-828):len(paid_players) == 1guard correctly prevents false dedup when a parent has multiple paid siblings. With 2+ paid players and no name match, the code falls through and creates a new player -- correct behavior.if not existing_player and form_token:gate ensures this fallback ONLY fires in the token flow (paid parents clicking email links). Walk-up flow (no token) is completely unaffected.existing_player.name = player_nameon line 832 updates the Stripe-sourced name to the form value. Downstream,player.nameis used for the confirmation page, so the parent sees the name they typed.player_name) from Stripe name (existing_player.name) for debugging.Edge case considered: Parent arrives via token, has 1 paid player, AND names happen to match (case-insensitive). The first query (line 799-806) catches this, so the fallback never fires. No double-match risk.
VERDICT: APPROVED
The fix is correct, minimal, and safe. The single-paid-player heuristic with the token-flow guard is the right approach for the known Stripe-vs-form name mismatch problem. The SOP gaps (no dedicated issue, branch not named after issue) and missing automated test are non-blocking given this is a time-sensitive bug fix for the March 13 tryout. Recommend backfilling the test and correcting the issue reference post-merge.