Skip to content

fix(jsonapi): Reject non-positive page[limit] - #5143

Merged
shepilov merged 1 commit into
linagora:masterfrom
RyoKusnadi:fix/reject-non-positive-page-limit
Nov 2, 2026
Merged

shepilov merged 1 commit into
linagora:masterfrom
RyoKusnadi:fix/reject-non-positive-page-limit

Conversation

@RyoKusnadi

Copy link
Copy Markdown
Contributor

ExtractPaginationCursor accepted page[limit]=0 or a negative value. The cursor then asked CouchDB for a limit of 0, which is omitted from the view request, so every row was read, and the next link kept pointing at the last row forever (an empty result even panicked on Rows[:-1]).

Now a page[limit] of 0 or less gets a 400 "page limit must be positive", like a page[limit] that is not a number.

Tested with a new unit test (0, -1, -2147483648 must give a 400 and no cursor): go test ./pkg/jsonapi.

Fixes #5128

A page[limit] of 0 or less was accepted, so the CouchDB limit was
dropped and the next links never ended. Answer with a 400 instead,
like for a page[limit] that is not a number.

Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>

@chibenwa chibenwa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit, thanks!

@shepilov
shepilov merged commit 41b55e4 into linagora:master Nov 2, 2026
4 checks passed
@RyoKusnadi
RyoKusnadi deleted the fix/reject-non-positive-page-limit branch November 5, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON:API pagination: page[limit]=-1 drops the CouchDB limit and makes the next links loop forever on the last row

3 participants