Bug: GET /teams/{id} returns 422 — tenant_id not auto-resolved like admin routes #372
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#372
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
Standalone — discovered during live CRM monitoring session 2026-04-07. Marcus reported "CRM is down" while browsing on iPhone.
Repo
forgejo_admin/basketball-apiWhat Broke
All 9 endpoints in
src/basketball_api/routes/teams.pyrequiretenant_idas a mandatory query parameter, but the frontend never sends it. This causes 422 Unprocessable Entity on any direct team page access.Admin routes (
admin.py:680) auto-resolve viadb.query(Tenant).first(). Schedule routes (schedule.py) use a_get_tenanthelper withDEFAULT_TENANT_SLUG. Theteams.pyrouter is the only one that doesn't auto-resolve — it's an inconsistency, not a design choice.Confirmed affected endpoints (all 9 in teams.py):
GET /teams(list)GET /teams/overviewGET /teams/mineGET /teams/{team_id}(detail) ← Marcus hit this onePOST /teams(create)PATCH /teams/{team_id}(update)DELETE /teams/{team_id}POST /teams/{team_id}/players(assign)DELETE /teams/{team_id}/players/{player_id}(unassign)Repro Steps
/teams/{id}Frontend call at
westside-landing/src/routes/(app)/teams/[id]/+page.svelte:13:Expected Behavior
Team detail page loads with roster, coaches, and team info. All teams endpoints work without explicit
tenant_id(auto-resolved like admin and schedule routes).Environment
basketball-api-6d89b9fc4f-ldjvc(running 16h)Acceptance Criteria
tenant_idoptional with auto-resolve fallbackschedule.py's_get_tenanthelper pattern withDEFAULT_TENANT_SLUGtenant_idexplicitly still work (backwards compatible)tenant_idFile Targets
src/basketball_api/routes/teams.py— maketenant_idoptional on all 9 endpoints, add_get_tenanthelpertests/test_teams.py— add no-tenant_id test cases for each endpointRelated
westside-basketball— project this affectsforgejo_admin/westside-landing— frontend that calls these endpoints without tenant_idschedule.py_get_tenanthelper — reference implementation for the fix patternScope Review: NEEDS_REFINEMENT
Review note:
review-877-2026-04-07Ticket has a mismatched story label and missing arch note. Blast radius is wider than title suggests.
Issues found:
arch-basketball-apiexists in pal-e-docs. Create it.teams.pyrequire explicittenant_idquery param. Clarify whether the fix covers 1 route or all 9.Scope refinement (post review-877-2026-04-07):
teams.py— codebase analysis confirmed all require explicittenant_idteams.py+test_teams.pyschedule.py's_get_tenanthelper as the fix patternWS-S1→WS-S10(admin manages coaches/teams)Scope Review: READY (re-review)
Review note:
review-877-2026-04-07All 4 refinement items from the previous NEEDS_REFINEMENT review have been addressed:
_get_tenanthelper usingDEFAULT_TENANT_SLUGNote for implementing agent: The scope says "all 9 routes" but
create_team(POST "") takestenant_idin the request body (TeamCreate model), not as a query param. The query-param fix applies to 8 routes.create_teamis a judgment call -- body-based tenant_id for creation is reasonable to keep.No decomposition needed -- mechanical transformation across 2 files, estimated 3-5 minutes.