Skip to content

REST: Send an empty pageToken on the first paginated request - #4511

Merged
Fokko merged 2 commits into
apache:mainfrom
Anurag-S1ngh:fix/4096-rest-page-token
Nov 30, 2026
Merged

Fokko merged 2 commits into
apache:mainfrom
Anurag-S1ngh:fix/4096-rest-page-token

Conversation

@Anurag-S1ngh

@Anurag-S1ngh Anurag-S1ngh commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Rationale for this change

Closes #4096.

When rest-page-size is set, list_namespaces, list_tables, and list_views sent pageSize without pageToken on the first request. The REST spec says a request without pageToken returns all results in one response, so compliant servers ignored rest-page-size, and some servers failed with a NumberFormatException.

The first request now always sends an empty pageToken to opt in to pagination, even when rest-page-size is not set, matching the Java client and letting the server use its default page size. Blank query values are kept when signing with SigV4 so the signed query matches the request that is sent.

Are these changes tested?

Yes. Updated the existing page size tests and added coverage for the first and subsequent pages, plus a SigV4 test that checks the blank pageToken survives signing. tests/catalog/test_rest.py passes with 201 tests, and uv run prek run --files pyiceberg/catalog/rest/__init__.py tests/catalog/test_rest.py passes.

Are there any user-facing changes?

No API changes. Pagination now works when rest-page-size is configured.

When rest-page-size is set, the first list request sent pageSize without pageToken, so servers returned all results in one response or failed. Send an empty pageToken to opt in to pagination, and keep blank query values when signing with SigV4.
Comment thread pyiceberg/catalog/rest/__init__.py Resolved
Comment thread tests/catalog/test_rest.py Resolved
Comment thread tests/catalog/test_rest.py Resolved
Match the Java client by sending pageToken= on the first request even when rest-page-size is unset, so servers paginate with their default page size instead of returning everything in one response.

Parametrize the pagination test over namespaces, tables, and views, and assert the canonical query string that gets signed so a blank pageToken cannot be dropped from the signature.

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks for aligning this with Java

@Fokko
Fokko enabled auto-merge November 30, 2026 14:04
@Fokko
Fokko added this pull request to the merge queue Nov 30, 2026
Merged via the queue into apache:main with commit 11dab82 Nov 30, 2026
24 of 26 checks passed
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.

REST: Send empty first-page pageToken when rest-page-size is set

2 participants