Repository navigation
fix(genre-tree): fail clearly when a full-list page returns no body - #175
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
It is a small, well-targeted null-guard fix whose premise is verified against the fetch-wrapper, with matching test coverage and a correct changelog entry, and no decoupling or export-wiring concerns.
Review effort: Balanced
Findings: None
What changed in this PR
This PR hardens fetchAllPages in the genre-tree module so that useListFullGenrePlaylists fails with a clear, actionable error instead of a TypeError. Previously, when any paginated page resolved to null (which the fetch-wrapper does when a handleError callback swallows a failure, on a 204, or when auth is missing), the subsequent flatMap over response.results threw an opaque TypeError. Now each page fetch is validated and rejects with Paginated list page N returned no body, which React Query surfaces as a normal query error. This improves observability of transient backend/auth failures in both consuming frontends.
Changes:
- Wrap each page fetch in
fetchRequiredPage, throwing a descriptive error when a page body isnull. - Add tests for a null first page, a null later page, and the
totalPages: 0short-circuit. - Add a
CHANGELOG.md[Unreleased] → Fixedentry.
| File | Description |
|---|---|
| packages/app-kit/src/genre-tree/useGenrePlaylist.ts | Adds fetchRequiredPage null-guard so paginated page fetches reject clearly instead of crashing in flatMap. |
| packages/app-kit/src/genre-tree/useGenrePlaylist.test.ts | Adds coverage for null first page, null later page, and totalPages: 0. |
| CHANGELOG.md | Documents the fix under [Unreleased] → Fixed. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
fetchAllPagescrashed with aTypeErrorinflatMapwhen any page resolved tonull. The fetch wrapper does that when ahandleErrorcallback swallows the failure, or on a 204. Now the query rejects withPaginated list page N returned no body, which React Query surfaces as a normal query error.Changes
useGenrePlaylist.ts:fetchAllPageswraps each page fetch and throws when the page is null.totalPages: 0.[Unreleased]→ Fixed.Test plan
pnpm lint && pnpm build && pnpm test(605 pass)🤖 Generated with Claude Code