Code RoomOffset pagination duplicates and gaps
HardPrep Room Coding #4071

Offset pagination duplicates and gaps

Vibe & agenticNetworking & APIsSenior–Staff~17 min

An AI assistant implemented this SQL-backed pagination for an admin user list. QA found that while paging through results during active sign-ups, some users appear twice across pages and some are never shown, and deep pages (offset 200000) are very slow.

Explain both problems and the better design.

Implement
keyset_page(rows: list[str], cursor: str, page_size: int) → list[str]
Examples
in[["u03|2026-01-03","u01|2026-01-01","u05|2026-01-03","u02|2026-01-02","u04|2026-01-04"],"",2]out["u04","u05"]
in[["u03|2026-01-03","u01|2026-01-01","u05|2026-01-03","u02|2026-01-02","u04|2026-01-04"],"u05|2026-01-03",2]out["u03","u02"]
in[["u03|2026-01-03","u01|2026-01-01","u05|2026-01-03","u02|2026-01-02","u04|2026-01-04","u06|2026-01-05"],"u05|2026-01-03",2]out["u03","u02"]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 17 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.