Skip to content

Fix off-by-one in /items pagination offset (DEMO-13) - #5

Draft
thierrypdamiba wants to merge 1 commit into
mainfrom
fix/buggy-api-20260803-201111
Draft

Fix off-by-one in /items pagination offset (DEMO-13)#5
thierrypdamiba wants to merge 1 commit into
mainfrom
fix/buggy-api-20260803-201111

Conversation

@thierrypdamiba

Copy link
Copy Markdown
Collaborator

This pull request was opened by an automated triage agent acting on behalf of Thierry Damiba (@thierrypdamiba), in response to a customer support email. Tracked as Linear ticket DEMO-13.

Bug

Customer report: page 1 of /items returned items 11–20 instead of 1–10, items 1–10 never appeared on any page, and pages overlapped.

Root cause in buggy-api/src/handler.py: the pagination offset was computed as page * limit for 1-indexed pages, so page 1 started at index 10 and the first limit items were never served.

Fix

offset = (page - 1) * limit

Tests

Before: tests/test_handler.py::test_page_one_starts_at_item_1 and tests/test_handler.py::test_all_pages_cover_all_items failed (page 1 returned item id 11; pages 1–3 covered only ids 11–25).

After: all 3 tests in buggy-api/tests/test_handler.py pass (3 passed).

Note for reviewers

The gateway's tool set has no label-writing tool, so this body is the record that an agent authored this PR. Policy forces this PR to draft; a human must promote it to ready-for-review.

Page 1 returned items 11-20 because the offset was computed as
page * limit instead of (page - 1) * limit, so the first page of
results was never served. Reported by a customer, tracked as DEMO-13.
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.

1 participant