Skip to content

Fix off-by-one in /items pagination offset (DEMO-25) - #18

Open
thierrypdamiba wants to merge 1 commit into
mainfrom
fix/buggy-api-20260803-230113
Open

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

Conversation

@thierrypdamiba

@thierrypdamiba thierrypdamiba commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

This pull request was opened by an automated triage agent acting on behalf of Thierry Damiba, in response to a customer support report tracked in Linear ticket DEMO-25.

Customer report: page 1 of the /items endpoint returned items 11 through 20 instead of 1 through 10, items 1 through 10 never appeared on any page, and page 2 repeated page 1's contents.

Root cause: in buggy-api/src/handler.py, get_page computed the offset as page times limit even though pages are 1-indexed. Page 1 therefore started at offset 10, skipping the first ten items, and every subsequent page showed the following page's data.

Fix: compute the offset as (page - 1) times limit, so page 1 starts at offset 0.

Verification, run in a Daytona sandbox: before the fix, pytest reported 2 failed and 1 passed (test_page_one_starts_at_item_1 and test_all_pages_cover_all_items failed). After the fix, all 3 tests pass: test_page_one_starts_at_item_1, test_page_two_starts_at_item_11, and test_all_pages_cover_all_items. Only the source was changed; no tests were modified.

Note for reviewers: the gateway 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 and merge.


Note

Low Risk
Single-line fix in demo pagination logic with no auth, security, or data-model changes.

Overview
Fixes off-by-one pagination in get_page so 1-indexed pages map to the right slice of ITEMS.

The offset changes from page * limit to (page - 1) * limit, so page 1 starts at item 1 (offset 0) instead of skipping the first page of results and duplicating later pages.

Reviewed by Cursor Bugbot for commit cbb7143. Bugbot is set up for automated code reviews on this repo. Configure here.

Page numbers are 1-indexed, but the offset was computed as
page * limit, so page 1 skipped the first `limit` items and every
page showed the next page's data. Compute offset as (page - 1) * limit
so page 1 starts at item 1 and all pages cover all items.
@thierrypdamiba
thierrypdamiba marked this pull request as ready for review August 3, 2026 23:17
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