fix: unwrap publicFetch response in teams page #145

Merged
forgejo_admin merged 1 commit from 143-fix-teams-page-unwrap into main 2026-03-28 19:10:10 +00:00

Summary

Fix teams page blank render by unwrapping API response object. publicFetch('/public/teams') returns {teams: [...]} but the page assigned the entire wrapper object to teams. .filter() on an object silently fails, so kingsTeams and queensTeams are always empty.

Changes

  • src/routes/(public)/teams/+page.svelte — changed teams = data to teams = data.teams ?? [] to extract the array from the wrapper object

Test Plan

  • Teams page renders Kings and Queens rosters
  • Kings/Queens toggle filters correctly
  • Empty response handled gracefully (fallback to [])

Review Checklist

  • One-line fix, no side effects
  • Null-safe with ?? [] fallback
  • No other places in the file assume data is an array directly

Closes #143

N/A — bug fix, no docs or notes impacted.

## Summary Fix teams page blank render by unwrapping API response object. `publicFetch('/public/teams')` returns `{teams: [...]}` but the page assigned the entire wrapper object to `teams`. `.filter()` on an object silently fails, so `kingsTeams` and `queensTeams` are always empty. ## Changes - `src/routes/(public)/teams/+page.svelte` — changed `teams = data` to `teams = data.teams ?? []` to extract the array from the wrapper object ## Test Plan - [ ] Teams page renders Kings and Queens rosters - [ ] Kings/Queens toggle filters correctly - [ ] Empty response handled gracefully (fallback to `[]`) ## Review Checklist - [x] One-line fix, no side effects - [x] Null-safe with `?? []` fallback - [x] No other places in the file assume `data` is an array directly ## Related Closes #143 ## Related Notes N/A — bug fix, no docs or notes impacted.
fix: unwrap publicFetch response in teams page
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
7be205a106
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>
Author
Owner

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/teams returns PublicTeamsResponse(teams=result) which serializes to {"teams": [...]}. The old code assigned the entire wrapper object to teams, so .filter() on line 65-66 silently returned undefined (not an array method on plain objects), causing kingsTeams and queensTeams to always be empty.

The fix teams = data.teams ?? [] correctly unwraps the response.

Edge case analysis:

  • data is null (API error) -- the if (data) guard on line 17 prevents entering the block; teams stays []. Safe.
  • data.teams is undefined (unexpected shape) -- ?? [] fallback catches it. Safe.
  • data.teams is [] (no teams exist) -- .filter() on empty array works correctly. Safe.
  • Happy path -- data.teams is a populated array, assigned directly. Correct.

API contract confirmed at /home/ldraney/basketball-api/src/basketball_api/routes/public.py:58-59:

class PublicTeamsResponse(BaseModel):
    teams: list[PublicTeamResponse]

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

  • Branch named after issue: 143-fix-teams-page-unwrap references issue #143
  • PR body follows template: Summary, Changes, Test Plan, Review Checklist, Related sections all present
  • Related references issue: "Closes #143"
  • No secrets committed
  • No unrelated file changes (1 file, 1 line)
  • Commit message is descriptive

PROCESS OBSERVATIONS

  • Test gap (non-blocking): The westside-app repo has zero frontend tests. This is not a blocker for a one-line bug fix, but it is a systemic risk. Any future feature work should be flagged for test coverage.
  • DORA impact: This is a fast fix with minimal change failure risk. Good example of small batch size.

VERDICT: APPROVED

## 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/teams` returns `PublicTeamsResponse(teams=result)` which serializes to `{"teams": [...]}`. The old code assigned the entire wrapper object to `teams`, so `.filter()` on line 65-66 silently returned `undefined` (not an array method on plain objects), causing `kingsTeams` and `queensTeams` to always be empty. The fix `teams = data.teams ?? []` correctly unwraps the response. **Edge case analysis:** - `data` is `null` (API error) -- the `if (data)` guard on line 17 prevents entering the block; `teams` stays `[]`. Safe. - `data.teams` is `undefined` (unexpected shape) -- `?? []` fallback catches it. Safe. - `data.teams` is `[]` (no teams exist) -- `.filter()` on empty array works correctly. Safe. - Happy path -- `data.teams` is a populated array, assigned directly. Correct. **API contract confirmed** at `/home/ldraney/basketball-api/src/basketball_api/routes/public.py:58-59`: ```python class PublicTeamsResponse(BaseModel): teams: list[PublicTeamResponse] ``` 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 - [x] Branch named after issue: `143-fix-teams-page-unwrap` references issue #143 - [x] PR body follows template: Summary, Changes, Test Plan, Review Checklist, Related sections all present - [x] Related references issue: "Closes #143" - [x] No secrets committed - [x] No unrelated file changes (1 file, 1 line) - [x] Commit message is descriptive ### PROCESS OBSERVATIONS - **Test gap (non-blocking):** The westside-app repo has zero frontend tests. This is not a blocker for a one-line bug fix, but it is a systemic risk. Any future feature work should be flagged for test coverage. - **DORA impact:** This is a fast fix with minimal change failure risk. Good example of small batch size. ### VERDICT: APPROVED
forgejo_admin deleted branch 143-fix-teams-page-unwrap 2026-03-28 19:10:10 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo_admin/westside-landing!145
No description provided.