Skip to content

fix(genre-tree): fail clearly when a full-list page returns no body - #175

Merged
Andreas-Garcia merged 1 commit into
developfrom
feature/full-list-null-page-guard
Oct 2, 2026
Merged

Andreas-Garcia merged 1 commit into
developfrom
feature/full-list-null-page-guard

Conversation

@Andreas-Garcia

Copy link
Copy Markdown
Member

Summary

fetchAllPages crashed with a TypeError in flatMap when any page resolved to null. The fetch wrapper does that when a handleError callback swallows the failure, or on a 204. Now the query rejects with Paginated list page N returned no body, which React Query surfaces as a normal query error.

Changes

  • useGenrePlaylist.ts: fetchAllPages wraps each page fetch and throws when the page is null.
  • Tests: null first page, null later page, and totalPages: 0.
  • CHANGELOG [Unreleased] → Fixed.

Test plan

  • pnpm lint && pnpm build && pnpm test (605 pass)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 2, 2026 01:23
@Andreas-Garcia
Andreas-Garcia merged commit a648faa into develop Oct 2, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 is null.
  • Add tests for a null first page, a null later page, and the totalPages: 0 short-circuit.
  • Add a CHANGELOG.md [Unreleased] → Fixed entry.
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.

@Andreas-Garcia
Andreas-Garcia deleted the feature/full-list-null-page-guard branch October 7, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants