bugproof-demo-shoplite · case_20260925_34fd
Last product never shows up in the catalog
The catalog pagination stopped showing the final product, hiding one product for customers. The bug was caused by a recent code change that used the wrong math to calculate how many pages there are. The page calculation was reverted to its original correct form, and the Next button now correctly shows all products, including the previously hidden Wool Pashmina Shawl.
Written by IBM watsonx.ai ibm/granite-4-h-small from the case evidence.
Reproduced — a new test failed before the fix
The Reproducer confirmed a failing test
Culprit commit identified
Pinned by git bisect in 6 steps · matches the seeded answer key · found by a follow-up bisect after publishing
882203d refactor(catalog): compute pagination bounds explicitly
Fixed — the repro test and the full suite pass
107 of 107 tests pass after the fix
Reviewed — the Critic approved
Verdict: APPROVED
APPROVED
Tests untouched — the fix changed no existing test
The fix commit only adds the repro test; no existing test was modified or deleted (git diff of the fix commit)
+ tests/bugproof/case_20260925_34fd.test.ts
The repro test fails on the code before the fix and passes on the fix.
git clone https://github.com/GegarinSagolsem/bugproof-demo-shoplite && cd bugproof-demo-shoplite && npm ci git checkout 35a91bf~1 # the code before the fix git checkout 35a91bf -- tests/bugproof/case_20260925_34fd.test.ts # add the repro test npx vitest run tests/bugproof/case_20260925_34fd.test.ts # fails: the bug is reproduced git checkout 35a91bf # the fix npx vitest run tests/bugproof/case_20260925_34fd.test.ts # passes
commit 882203d08ced62a9c0b0bda9829395451ab75a54
Author: GegarinSagolsem <176033453+GegarinSagolsem@users.noreply.github.com>
Date: Fri Sep 25 18:56:00 2026 +0000
refactor(catalog): compute pagination bounds explicitly
---
src/catalog/paginate.ts | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/catalog/paginate.ts b/src/catalog/paginate.ts
index 128b811..28e7a38 100644
--- a/src/catalog/paginate.ts
+++ b/src/catalog/paginate.ts
@@ -13,11 +13,13 @@ export function paginate<T>(items: readonly T[], page: number, pageSize: number)
if (!Number.isInteger(pageSize) || pageSize < 1) {
throw new RangeError(`pageSize must be a positive integer, got ${pageSize}`);
}
- const totalPages = Math.max(1, Math.ceil(items.length / pageSize));
+ const lastIndex = items.length - 1;
+ const totalPages = Math.max(1, Math.ceil(lastIndex / pageSize));
const current = Math.min(Math.max(1, Math.floor(page)), totalPages);
const start = (current - 1) * pageSize;
+ const end = Math.min(start + pageSize, items.length);
return {
- items: items.slice(start, start + pageSize),
+ items: items.slice(start, end),
page: current,
pageSize,
totalItems: items.length,
Updated after publishing: a follow-up bisect on 2026-09-26 04:49 UTC identified the culprit 882203d. The Lead wrote the summary below before that.
Bug: commit 882203d introduced `const lastIndex = items.length - 1` and replaced `Math.ceil(items.length / pageSize)` with `Math.ceil(lastIndex / pageSize)` in src/catalog/paginate.ts. For 25 products at 6 per page, this computed totalPages=4 instead of 5, making the Next button disable one page too early and leaving the Wool Pashmina Shawl unreachable. Fix: removed the erroneous `lastIndex` variable and restored `Math.ceil(items.length / pageSize)`. Repro test (3 assertions) went RED→GREEN. Full suite: 107/107 passed. Critic: APPROVED.