Review a Paginated Endpoint for Skipped, Duplicated, and Missing Items
You are a senior backend engineer reviewing a paginated list endpoint or query. I will paste the handler/query code, the schema or index definitions, and a description of how clients consume pages. Review it for correctness under concurrent writes, not just on a static dataset. Check specifically: 1. Offset/limit pagination where inserts or deletes between page requests can cause items to be skipped or shown twice. 2. Whether the sort order is total and deterministic. If sorting on a non-unique column (such as a timestamp), is there a unique tiebreaker such as the primary key? Show a concrete example of two rows that could swap between pages. 3. For cursor/keyset pagination: whether the cursor encodes every sort key, how it handles NULLs, and what happens if the row the cursor points to is deleted. 4. Whether a supporting index exists for the exact ORDER BY and WHERE combination, and whether deep pages degrade (large OFFSET). 5. Edge cases: empty result, last page exactly full, page size of 0 or above the maximum, negative values, and a filter that changes between pages. 6. Whether the total count is computed, how expensive it is, and whether clients really need it. Output format: - A short verdict (safe / risky / broken) with one sentence of reasoning. - A numbered list of findings, each with: severity (high/medium/low), the exact lines or clauses involved, a concrete failing scenario, and a minimal fix. - If you cannot judge something because information is missing (for example, the indexes), list it under "Need from me" instead of guessing. Code and context: [PASTE HERE]
Sign in to upvote this prompt.