All problems

Filter Scope Mismatch in Search Cursors

Level 2 · node · API · Cursor pagination contract

Scenario

A product search API combines a category filter with cursor-based pagination. The first page looks correct, but requesting the next page for a category can mix in products from another category or skip products that belong to the requested category. The controller, search service, repository, and cursor codec are separated.

Requirements

- When category is specified, every page contains only products from that category - nextCursor points to the next position within the currently filtered result set - A request without a cursor returns the first filtered page - The final page returns nextCursor as null - Following cursors to the end for one category returns every matching product exactly once with no gaps

Acceptance criteria

  • The first page for a category filter contains only products from that category
  • The second page preserves the same category scope
  • Following all cursors returns every filtered product once with no duplicates or omissions
  • The final page has a null nextCursor
  • A nonexistent category returns empty items and a null nextCursor