AC-036 Scenario not caught

The pagination contract is broken

Behaviour a schema cannot see

How to run this card's commands yourself

1. The problem

In one sentence

A list that is split into pages gives wrong answers about the pages: it says there is more when there is not, or it returns data for a page that does not exist.

A story

A client reads a product list page by page and stops when the answer says has_more: false. The server sets has_more: true on every page, the last one too. The client asks for page 4, then 5, then 6, and never stops. In a second API, asking for page 99 of a three-page list does not return an empty page: it returns the first page again, so a client that loops until the list is empty loops forever.

Why it hurts

Paging is a contract between the server and every client that reads a list. Each field (has_more, count, the page number) tells the client when to stop. When one is wrong, the client either misses data or never finishes.

  • For developers: every field in the answer is valid, with the right type and shape. The fault is in the value, and it shows only across several requests in a row.
  • For managers: an export that never finishes loads the servers, fills storage and hides the cause. An export that stops early silently loses records.
  • For DevOps: a runaway page loop is a load problem. Cap the number of pages a job may read, and test the last page and the page after it.

Example

A list of 5 products, limit=2, so 3 pages:

GET /products?page=1&limit=2   ->  has_more: true     (correct)
GET /products?page=2&limit=2   ->  has_more: true     (correct)
GET /products?page=3&limit=2   ->  has_more: true     (wrong: it is the last page)

And for a list of 3 items:

GET /items?page=1    ->  count: 3
GET /items?page=99   ->  count: 3     (wrong: must be an empty result, count 0)

How to detect it without clrsig

  • Walk the pages by hand with curl and jq, and look at the last page and the page after it.
  • Compare the sum of items over all pages with the total the API reports.

How to fix it

There are two usual causes:

  1. The code is wrong (more likely). Compute has_more from the real position (offset plus page size against the total). Return an empty list for a page past the end, never wrap around.
  2. The spec is silent. Say what the fields mean and what a page beyond the end returns.

To tell which: ask what a client should do on the last page. The answer must be written in the spec. Never leave the last-page behaviour undefined.

AC-037 A filter, limit or sort parameter is ignored, AC-018 A response grows too large, AC-040 A business rule is broken though every response looks fine. More failure-catalog demos: FM-003-03 (an off-by-one in the page offset) and FM-003-04 (missing pagination metadata). See also the site’s Pagination Contract Failures.

Words used on this page are explained once in the glossary.

2. How clrsig helps

Check

No built-in check, and the state is not caught. Each response matches its schema, so a single-request check passes on both the broken and the fixed server. A multi-step scenario with value assertions finds it: request page 1, page 2, then page 3, and check the field each time.

Command

Each demo is a runnable server in the failure catalog. These scenarios only read data (GET). From the demo folder, with Go installed:

cd failures/fm-003-01-pagination-contract
go run broken/main.go &
clrsig run scenarios/detect.yaml --env environments/local.yaml

Exit code: 0 all steps pass, 1 a step failed, 2 the scenario or the setup is broken. Here it is 1. Against fixed/main.go all three steps pass and the exit code is 0.

What you see

Output from clrsig v0.21.0, recorded on 2026-11-30. First fm-003-01-pagination-contract:

Scenario: fm-003-01 — Pagination Contract Failures

  PASS  page 1 of 3 (limit=2, 5 total): has_more must be true  200  11ms
         ✓ jsonpath $.has_more eq true
  PASS  page 2 of 3 (limit=2, 5 total): has_more must be true  200  0ms
         ✓ jsonpath $.has_more eq true
  FAIL  page 3 of 3 (limit=2, 5 total): has_more must be false — no more pages  200  0ms
         ✗ jsonpath $.has_more eq false: expected "false"; got "true"

FAILED  2 passed, 1 failed, 0 skipped  (2/3 assertions passed)  12ms

Then fm-003-02-page-overflow:

Output from clrsig v0.21.0, recorded on 2026-11-30:

Scenario: fm-003-02 — Page Overflow Returns Wrong Data

  PASS  page=1 — returns items normally  200  10ms
         ✓ jsonpath $.count eq 3
  FAIL  page=99 — beyond last page, must return empty result (count=0)  200  0ms
         ✗ jsonpath $.count eq 0: expected "0"; got "3"

FAILED  1 passed, 1 failed, 0 skipped  (1/2 assertions passed)  11ms

How to read it: the first two pages pass, and only the last page shows the fault. A one-request check would have stopped at page 1.

Where to look

  • Desktop app: open the scenario and run it; each step shows its assertion result.
  • Reports: --format json and junit on clrsig run.
  • GitHub Action: use command: run with the scenario and env inputs. Some of these demo scenarios name their spec with specFile; the others check only their own assertions. To compare your own responses with your spec, name it with specFile in the scenario, or give the spec input, which replaces it; older releases of the Action ignored that input with run (setup and upgrading).

How clrsig helps you fix it

It points at the exact page where the field is wrong. It does not know your paging rules; you write them in the assertions, and they become the executable contract.

Limits

  • Only the pages and values you write are tested. Test the first page, the last page and the page after the last.
  • A scenario with fixed data needs a stable data set, so the counts stay the same.

More ways

Nothing yet.

3. Video brief for Google NotebookLM

VIDEO BRIEF — AC-036 · The pagination contract is broken
Length: 5 to 7 minutes. Language: English. Audience: developers, with a line each for managers and DevOps.
One idea: every field in a paged answer is a signal that tells the client when to stop; the fault is in the value, and it shows only across several requests.
Open with this story: A client reads a product list page by page and stops when the answer says has_more is false. The server sets has_more to true on every page, the last one too. The client asks for page 4, then 5, then 6, and never stops. In a second API, asking for page 99 of a three-page list returns the first page again, so a client that loops until the list is empty loops forever.
Say these facts, in this order:
1. A list of 5 products with a limit of 2 has 3 pages. The scenario asks for pages 1, 2 and 3.
2. Pages 1 and 2 are right. Page 3 says has_more true; it must be false.
3. A single-request check passes on both the broken and the fixed server; it takes a scenario.
4. The second demo: page 99 of a 3-item list returns a count of 3; it must be an empty result with a count of 0.
5. Two usual causes: the code is wrong (compute has_more from the real position; return an empty list past the end), or the spec is silent about what the fields mean.
6. For managers: an export that never finishes loads the servers; one that stops early silently loses records.
7. For DevOps: cap the number of pages a job may read; test the last page and the page after it.
Show on screen: the example lines, the commands (go run broken/main.go and clrsig run scenarios/detect.yaml --env environments/local.yaml), and the two output blocks, copied exactly from the card.
Name the check: none built in; found by value assertions in a multi-step scenario. Say the clrsig version: v0.21.0.
Explain these words once: paging (returning a long list in pieces); has_more (a field that says whether another page follows); scenario (a script of steps with your own checks, called assertions); exit code (0 clean, 1 a finding, 2 setup or spec broken).
Say what clrsig does not see here: only the pages and values you write are tested; fixed counts need a stable data set.
Safety line (if a write is shown): not needed, these scenarios only send GET requests.
Finish with three recap questions:
1. What must has_more be on the last page? (False.)
2. What must a page past the end return? (An empty result.)
3. Why does a one-request check miss this? (Every single answer is valid; the fault shows across requests.)
Tease the next video: AC-037 · A filter, limit or sort parameter is ignored.
Do not: say "contract testing" alone; say clrsig "catches everything"; invent flags, IDs or numbers; read tables aloud; use any fact that is not in the card.