Fix: confirmation email skipped for existing Keycloak accounts + token=None in profile URL #390
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#390
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Type
Bug
Lineage
Discovered during registration flow validation (2026-04-07) while testing #383 fix.
Repo
forgejo_admin/basketball-apiWhat Broke
Two related issues in the promo registration path:
Confirmation email not sent for existing Keycloak accounts.
send_confirmation_email()is nested insideif keycloak_credentials:inregister.py:1402. If the Keycloak account already exists,create_account_for_parent()returns None, and no confirmation email is sent. Re-registering parents get nothing.token=Nonein profile URL. The plaintext email body includesregister?token=Nonebecause the parent'sregistration_tokenwas not generated before the email was built. The token generation happens inregistration.py:77-78but may not fire for existing parents in the promo path.Repro Steps
Expected Behavior
Environment
Production, basketball-api, promo registration path.
File Targets
src/basketball_api/routes/register.py— movesend_confirmation_email()call outside theif keycloak_credentials:block (line ~1402). Call it unconditionally after successful registration. Passcredentials=keycloak_credentials(which will be None for existing accounts, causing the email to send without the login credentials block).src/basketball_api/routes/webhooks.py— apply the same fix at line ~347. The webhook path has an identicalif keycloak_credentials:guard aroundsend_confirmation_email(). Move it outside the guard so webhook-completed registrations for existing Keycloak accounts also receive confirmation emails.src/basketball_api/services/registration.py— ensureregistration_tokenis generated for existing parents (line 77-78)Acceptance Criteria
Test Expectations
pytest tests/ -k test_registerConstraints
credentials=Nonetosend_confirmation_email()so it sends without the login credentials blocksend_confirmation_email()already handlescredentials=Nonegracefully (the credentials parameter is optional)Checklist
Related
westside-basketballScope Review: NEEDS_REFINEMENT
Review note:
review-891-2026-04-08Scope is solid with all bug template sections present and both file targets verified. Two issues found:
webhooks.py:347has identicalif keycloak_credentials:guard aroundsend_confirmation_email(). AC #3 implies this should be fixed but it's not listed as a file target. Addsrc/basketball_api/routes/webhooks.pyas a file target.arch:emaillabel is set but noarch-emailnote exists in pal-e-docs. Needs creation (separate scope item).credentials=Noneexplicitly so email sends without the credentials block.Scope refinement applied (review-891-2026-04-08):
webhooks.py:~347as file target — identicalif keycloak_credentials:guard exists in the webhook pathcredentials=Nonebehavior — explicitly noted that existing accounts pass None to skip the login credentials blockArch note gap (
arch:emaillabel with no backing note) tracked as separate backlog item.Scope Review: READY
Review note:
review-891-2026-04-08Re-review after refinements: all file targets verified (register.py:1402, webhooks.py:347, registration.py:77-78), template complete, traceability solid (story:WS-S22 confirmed, arch-email note tracked separately). 4 ACs are testable, blast radius checked (3rd call site in registration.py:126 is already correct). Single-repo, single-agent scope (~3 min).
Validation: PASS
Tiers executed: Tier 1 (local tests), Tier 3 (production health)
Validation note:
validation-390-2026-04-087 checks: 7 PASS, 0 FAIL
Summary:
2d85242includes PR #396 commit, API endpoints responding