Paging is clamped silently, and the clamped values are what is reported
The rule
- A paginated endpoint MUST use a
limitof 50 where the request carries none. - It MUST cap
limitat 100. - It MUST raise a
limitbelow 1 to 1. - It MUST floor
offsetat 0. - A
limitthat is not an integer MUST be corrected to the default of 50, and anoffsetthat is not an integer MUST be corrected to 0. - Out-of-range or malformed paging MUST be corrected and MUST NOT be refused: there is no 400 for it, and the conventions' 400 for a malformed query parameter does not apply to
limitoroffset. - The pagination block MUST report the values used, defaulted or corrected, so a caller that asked for 1000 and was served 100 is told 100 and its
has_morearithmetic holds. totalMUST be counted before pagination and under every filter the result carries, so a filtered page's total describes the filtered set and not the whole collection.
What it means
Out-of-range paging is corrected, not refused — there is no 400 for asking
for too much or for a negative offset. But the correction is not silent in
the sense of invisible: the values reported back are the ones actually used,
so a caller who asked for far more rows than the cap allows is told the
capped number, and its own arithmetic on has_more still holds.
The correction goes to the nearest value in range at both ends. A limit above
100 becomes 100; a limit of 0 or below becomes 1. The lower bound matters as much
as the cap: with a limit of 0 a page holds no rows, offset + limit never grows,
and has_more would stay true for a client that pages until it turns false. A
request that names no limit gets 50, and is told so. A limit that is not an
integer at all, such as limit=ten or limit=2.5, is treated the same way and
gets 50; an offset that is not an integer gets 0. Paging is the one place a
malformed query parameter is corrected rather than refused, so a client's bad
paging value costs it a page, never the request.
total is counted before pagination is applied, and under whatever filter
the request carries. A filtered page's total describes the filtered set, not
the whole collection — a search that matches nothing is an empty page with a
total of zero, not the size of the unfiltered table.
Example
Asking for far more than the cap still gets a coherent, corrected answer.
GET /api/flowdrop/workflows?limit=1000
{"pagination": {"total": 3, "limit": 100, "offset": 0, "has_more": false}}A limit of zero is raised to one, so paging always moves forward.
GET /api/flowdrop/workflows?limit=0
{"pagination": {"total": 3, "limit": 1, "offset": 0, "has_more": true}}A filter that matches nothing still gets a well-formed, empty page.
GET /api/flowdrop/workflows?search=nothing+here
{"pagination": {"total": 0, "limit": 50, "offset": 0, "has_more": false}}total is the filtered count in both cases, never the size of the whole
collection behind it.
Why
A default of 50. The default is what a client gets when it says nothing, so it has to be within the cap and large enough that a typical list screen fills from one page. Half the cap does both, and leaves a client that wants the most rows a reason to ask for them explicitly.