Rerun-collection picker in SchedulesScreen silently truncates at 100 (asks for pageSize 1000, server clamps to 100) #634

Closed
opened 2026-07-25 23:42:51 +02:00 by timothy · 2 comments
Owner

Split out of #616. The off-by-one there (pageNum: 1, which skipped the whole first page) is fixed; this is the remaining, smaller defect of the same class in the same call.

web/src/screens/SchedulesScreen.tsx loads the rerun-collection picker with getRerunCollections({ pageNum: 0, pageSize: 1000 }). RerunCollectionController clamps pageSize to 100 (Math.Clamp(pageSize, 1, MaxPageSize)), so the request is served 100 rows regardless. The pageSize: 1000 clearly encodes an intent of "give me all of them".

So with more than 100 rerun collections, the picker silently omits the rest — no error, no truncation indicator, and a schedule item simply cannot be pointed at a rerun collection that exists. Same silent-short-set shape as #616, just gated on a larger library.

Not urgent (it needs >100 rerun collections to bite) and deliberately left out of the #616 PR to keep that diff to the confirmed defects.

Fix

Page to completeness against totalCount, the way CollectionsScreen.enterReorder already does for collection items — fetch page 0, then keep requesting while loaded < totalCount. Prefer reusing that pattern over raising the server cap; api.search-allitems-paging set the precedent that the client pages to completeness rather than the server returning unbounded lists.

Worth checking the other Promise.all picker loads in loadPickerData for the same assumption while you are there — several fetch a list with no paging at all.

Done-when

  • The rerun-collection picker returns every rerun collection regardless of count
  • A test covers the >100 case (mock totalCount above one page and assert the picker sees all of them)
  • The other picker loads in loadPickerData are checked for the same silent-truncation assumption
  • Adversarial review passed
Split out of #616. The off-by-one there (`pageNum: 1`, which skipped the whole first page) is fixed; this is the remaining, smaller defect of the same class in the same call. `web/src/screens/SchedulesScreen.tsx` loads the rerun-collection picker with `getRerunCollections({ pageNum: 0, pageSize: 1000 })`. `RerunCollectionController` clamps `pageSize` to **100** (`Math.Clamp(pageSize, 1, MaxPageSize)`), so the request is served 100 rows regardless. The `pageSize: 1000` clearly encodes an intent of "give me all of them". So with more than 100 rerun collections, the picker silently omits the rest — no error, no truncation indicator, and a schedule item simply cannot be pointed at a rerun collection that exists. Same silent-short-set shape as #616, just gated on a larger library. Not urgent (it needs >100 rerun collections to bite) and deliberately left out of the #616 PR to keep that diff to the confirmed defects. ## Fix Page to completeness against `totalCount`, the way `CollectionsScreen.enterReorder` already does for collection items — fetch page 0, then keep requesting while `loaded < totalCount`. Prefer reusing that pattern over raising the server cap; `api.search-allitems-paging` set the precedent that the client pages to completeness rather than the server returning unbounded lists. Worth checking the other `Promise.all` picker loads in `loadPickerData` for the same assumption while you are there — several fetch a list with no paging at all. ## Done-when - [x] The rerun-collection picker returns every rerun collection regardless of count - [x] A test covers the >100 case (mock `totalCount` above one page and assert the picker sees all of them) - [x] The other picker loads in `loadPickerData` are checked for the same silent-truncation assumption - [x] Adversarial review passed
timothy added the bugapi labels 2026-07-25 23:42:51 +02:00
timothy added the priority: low label 2026-07-25 23:54:10 +02:00
timothy added the in-progress label 2026-07-26 10:57:33 +02:00
Author
Owner

Claiming — bundled with #633 this session (both split out of #616's paging cluster; disjoint file sets, so they run as parallel slices).

Claiming — bundled with #633 this session (both split out of #616's paging cluster; disjoint file sets, so they run as parallel slices).
Author
Owner

Closing record

Outcome: Shipped in PR #645 (merged as 5f3623b3). SchedulesScreen's rerun-collection picker now pages to completeness against totalCount via loadAllRerunCollections() instead of issuing one pageSize: 1000 request the server clamps to 100.

Root cause: A client asking for a page size larger than the endpoint's cap, and treating the single response as the whole list. RerunCollectionController clamps to MaxPageSize = 100, so the pageSize: 1000 encoded an intent ("give me all of them") the API never promised to honour. Past 100 rerun collections the extras vanished with no error and no truncation indicator — a schedule item simply could not be pointed at a rerun collection that existed.

Decisions/conventions changed: None. This upholds existing api.paging-zero-based and api.search-allitems-paging (the client pages to completeness; the server stays bounded) rather than changing either. The server cap was deliberately not raised.

Reusable knowledge:

  • A regression test can encode an invariant the correct fix must violate. The #616 guard asserted every rerun request used pageNum=0. True while exactly one request was ever issued — but legitimate paging walks 1, 2, …, so the assertion described something correct code does not do. It passed only because the fixture's totalCount fits one page; raising that default would have failed the #616 test with a misleading "requested page 1" signal, sending the next reader after a defect that isn't there. When a fix changes how many calls a code path makes, re-read the tests that assert on all of them.
  • The fix's own scope was one screen; the defect's scope was eight. Grep found seven more call sites of the same shape — filed as #644. Notably RerunCollectionsScreen.tsx:136, which means this fix lets a schedule reference rerun collection #120 while the screen that creates and edits it still cannot show it.

Verification: npx vitest run src/screens/SchedulesScreen.test.tsx 27 passed; full web suite 997 passed; tsc -b and eslint clean; full CI green on head f9380eb4. Mutation-verified: forcing the loop to stop after page 0 reddens the new test (expected 1 to be 2). The new test pins the exact 150-element option set with toEqual, not a non-empty check. The independent reviewer separately mutation-verified the narrowed #616 guard — reintroducing the original #616 defect still fails that test with its own message. No live-E2E: read-only SPA load path, no write path or server state touched.

Deferred: The seven sibling truncating call sites → #644 (priority: medium). Two review nits declined with reasons: the concurrent-insert duplicate-row window (inherent to offset paging, identical in the mirrored CollectionsScreen.enterReorder precedent) and raising the server cap (rejected on api.search-allitems-paging grounds).

Docs updated: None required — no convention, route, endpoint or decision changed. The api.paging-zero-based contract this upholds is documented by the sibling issue #633.

## Closing record **Outcome:** Shipped in PR #645 (merged as `5f3623b3`). `SchedulesScreen`'s rerun-collection picker now pages to completeness against `totalCount` via `loadAllRerunCollections()` instead of issuing one `pageSize: 1000` request the server clamps to 100. **Root cause:** A client asking for a page size larger than the endpoint's cap, and treating the single response as the whole list. `RerunCollectionController` clamps to `MaxPageSize = 100`, so the `pageSize: 1000` encoded an intent ("give me all of them") the API never promised to honour. Past 100 rerun collections the extras vanished with no error and no truncation indicator — a schedule item simply could not be pointed at a rerun collection that existed. **Decisions/conventions changed:** None. This upholds existing `api.paging-zero-based` and `api.search-allitems-paging` (the client pages to completeness; the server stays bounded) rather than changing either. The server cap was deliberately not raised. **Reusable knowledge:** - **A regression test can encode an invariant the correct fix must violate.** The #616 guard asserted *every* rerun request used `pageNum=0`. True while exactly one request was ever issued — but legitimate paging walks 1, 2, …, so the assertion described something correct code does not do. It passed only because the fixture's `totalCount` fits one page; raising that default would have failed the #616 test with a misleading "requested page 1" signal, sending the next reader after a defect that isn't there. When a fix changes *how many* calls a code path makes, re-read the tests that assert on *all* of them. - **The fix's own scope was one screen; the defect's scope was eight.** Grep found seven more call sites of the same shape — filed as #644. Notably `RerunCollectionsScreen.tsx:136`, which means this fix lets a schedule *reference* rerun collection #120 while the screen that creates and edits it still cannot show it. **Verification:** `npx vitest run src/screens/SchedulesScreen.test.tsx` 27 passed; full web suite 997 passed; `tsc -b` and eslint clean; full CI green on head `f9380eb4`. Mutation-verified: forcing the loop to stop after page 0 reddens the new test (`expected 1 to be 2`). The new test pins the exact 150-element option set with `toEqual`, not a non-empty check. The independent reviewer separately mutation-verified the narrowed #616 guard — reintroducing the original #616 defect still fails that test with its own message. No live-E2E: read-only SPA load path, no write path or server state touched. **Deferred:** The seven sibling truncating call sites → **#644** (`priority: medium`). Two review nits declined with reasons: the concurrent-insert duplicate-row window (inherent to offset paging, identical in the mirrored `CollectionsScreen.enterReorder` precedent) and raising the server cap (rejected on `api.search-allitems-paging` grounds). **Docs updated:** None required — no convention, route, endpoint or decision changed. The `api.paging-zero-based` contract this upholds is documented by the sibling issue #633.
timothy removed the in-progress label 2026-07-26 12:21:18 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: timothy/ersatztv#634