API Testing / Editorial solution guide
Diagnose missing and duplicate records across API pages
Compare page identities, ordering and cursor scope when the total count appears correct.
Read-only knowledge base · No public comments
Recognize the symptoms
A client collects the expected number of records across pages, but one synthetic record is missing and another appears twice. The total count can look correct even when the set of identities is wrong. Preserve each response and cursor before rerunning.
Understand the likely causes
- An unstable ordering, equal sort values without a documented tie-breaker, changes between requests, a cursor used with a different filter, or a client merge defect can produce this symptom. Determine the API’s documented consistency contract before treating any particular behavior as a defect.
1. Preserve the contract and page evidence
Record the API revision, synthetic dataset, filter, sort order, page size, cursor sequence and response identifiers. Keep credentials and personal data out of the report. Note whether the contract promises a stable snapshot, a stable order only, or permits changes while paging. Compare the collected identity set with an independently prepared expected set, not just its count. If data changed between requests, preserve the change timeline rather than assuming the pages describe one fixed snapshot.
2. Reproduce with controlled records
In an authorized isolated service create synthetic records with distinct identifiers and at least two equal primary sort values. Request each page using the documented cursor and unchanged filter, then record every returned identifier and cursor. Compare a run without concurrent changes to the original failure. If the contract permits changes between pages, separately exercise that behavior rather than inventing snapshot guarantees. Check whether the client merges or deduplicates results differently from the raw responses.
3. Identify the responsible boundary
Find the first page where the expected and observed identity sequences diverge. Compare the provider’s documented ordering and tie-breaker with the actual controlled result, then examine whether cursor scope matches the filter and ordering. If raw pages are correct but the collected list differs, investigate the client merge. If the provider violates its stated contract, correct that specific behavior in the isolated environment. Do not silently discard duplicates merely to make the count match.
4. Verify identities and edge cases
Repeat the original fixture and a second page size, checking each identity exactly as required by the contract and confirming that no unexpected identity appears. Include equal sort values and the last partial page. Exercise a changed filter or concurrent update only under its documented semantics, and record any unsupported scenario. Preserve the revision, request sequence and raw synthetic responses. Passing these cases supports the tested pagination behavior; it does not prove consistency under every dataset or concurrent schedule.
Verify the fix
The controlled static dataset yields the documented ordered identities without missing or duplicated records, and the client’s collected list matches the raw pages. Any concurrent-change limitation is recorded.
Keep it from recurring
- Specify ordering, cursor scope and consistency semantics in the API contract. Maintain synthetic regression fixtures with equal sort values, multiple page sizes and identity-level assertions.