fix: unwrap publicFetch response in teams page #145
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/westside-landing!145
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "143-fix-teams-page-unwrap"
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
Fix teams page blank render by unwrapping API response object.
publicFetch('/public/teams')returns{teams: [...]}but the page assigned the entire wrapper object toteams..filter()on an object silently fails, sokingsTeamsandqueensTeamsare always empty.Changes
src/routes/(public)/teams/+page.svelte— changedteams = datatoteams = data.teams ?? []to extract the array from the wrapper objectTest Plan
[])Review Checklist
?? []fallbackdatais an array directlyRelated
Closes #143
Related Notes
N/A — bug fix, no docs or notes impacted.
The /public/teams endpoint returns {teams: [...]} but the page assigned the entire wrapper object. .filter() on an object silently fails, rendering an empty page. Closes #143 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>PR #145 Review
DOMAIN REVIEW
Stack: SvelteKit (Svelte 5 runes), vanilla CSS, public-facing landing page.
Fix correctness verified. The basketball-api endpoint
GET /public/teamsreturnsPublicTeamsResponse(teams=result)which serializes to{"teams": [...]}. The old code assigned the entire wrapper object toteams, so.filter()on line 65-66 silently returnedundefined(not an array method on plain objects), causingkingsTeamsandqueensTeamsto always be empty.The fix
teams = data.teams ?? []correctly unwraps the response.Edge case analysis:
dataisnull(API error) -- theif (data)guard on line 17 prevents entering the block;teamsstays[]. Safe.data.teamsisundefined(unexpected shape) --?? []fallback catches it. Safe.data.teamsis[](no teams exist) --.filter()on empty array works correctly. Safe.data.teamsis a populated array, assigned directly. Correct.API contract confirmed at
/home/ldraney/basketball-api/src/basketball_api/routes/public.py:58-59:And the return statement at line 144:
return PublicTeamsResponse(teams=result). The fix matches the contract exactly.BLOCKERS
None. This is a one-line bug fix restoring existing functionality, not new functionality. No security surface (public read-only endpoint, no user input). No secrets. No auth logic.
NITS
None. The fix is minimal, correct, and null-safe.
SOP COMPLIANCE
143-fix-teams-page-unwrapreferences issue #143PROCESS OBSERVATIONS
VERDICT: APPROVED