Skip to content

Fix Paginator dropping results on empty token pages#818

Merged
hectorcast-db merged 3 commits into
mainfrom
deco-27280-paginator-empty-page
Jun 4, 2026
Merged

Fix Paginator dropping results on empty token pages#818
hectorcast-db merged 3 commits into
mainfrom
deco-27280-paginator-empty-page

Conversation

@hectorcast-db
Copy link
Copy Markdown
Contributor

@hectorcast-db hectorcast-db commented Jun 3, 2026

Summary

Fix Paginator silently dropping results when a token-paginated response returns an empty page that still carries a next_page_token. Adds explicit newTokenPagination / newOffsetPagination factories and regenerates all list methods to use them. Backward compatible — the existing constructor is kept and deprecated.

Why

Token-paginated endpoints (e.g. tables().list()) may return empty intermediate pages with a valid next_page_token — the only reliable end-of-results signal is the token's absence. Paginator stopped at the first empty page, so these calls under-returned results. Offset/limit APIs (SCIM, legacy SQL) have no token and do end on an empty page, so the fix is strategy-aware (a blanket "skip empty pages" would loop those forever).

What changed

  • Paginator.newTokenPagination(...) — page until nextPageFn returns null; empty pages are skipped.
  • Paginator.newOffsetPagination(...) — stop on the first empty page (previous behavior).
  • The existing Paginator constructor is kept and @Deprecated, retaining its prior offset/limit behavior — no breaking change.
  • Regenerated *API.java (91 token / 34 offset). Hand-written: SharesExtAPI → token; SCIM Users/Groups/ServicePrincipals + Account* → offset.

How is this tested?

  • PaginatorTest: token pagination walks past empty leading/intermediate pages; offset pagination still stops on the first empty page.
  • mvn clean compile over the full regenerated SDK (3,902 sources) passes.

@hectorcast-db hectorcast-db force-pushed the deco-27280-paginator-empty-page branch from 2f28576 to 136e5a0 Compare June 3, 2026 07:10
@hectorcast-db hectorcast-db force-pushed the deco-27280-paginator-empty-page branch from 136e5a0 to b2f9743 Compare June 3, 2026 07:27
@hectorcast-db hectorcast-db force-pushed the deco-27280-paginator-empty-page branch from b2f9743 to 06008a3 Compare June 3, 2026 07:35
@hectorcast-db hectorcast-db changed the title Fix Paginator dropping results on empty token pages (DECO-27280) Fix Paginator dropping results on empty token pages Jun 3, 2026
The Paginator stopped iterating at the first empty page even when the
response carried a non-empty next_page_token, silently dropping results
on later pages. Token-paginated list methods (e.g. tables().list()) can
return empty intermediate pages with a valid token, so results could be
under-returned.

Add two explicit pagination factories:
  - Paginator.newTokenPagination: iterate until nextPageFn returns null;
    empty pages are skipped, not treated as the end of results.
  - Paginator.newOffsetPagination: stop on the first empty page (offset,
    SCIM and legacy SQL APIs have no token and rely on this).
The existing Paginator constructor is kept and deprecated (it retains its
previous offset/limit behavior), so this is not a breaking change.

Regenerate all *API.java list methods to the appropriate factory. Update
hand-written APIs: SharesExtAPI -> newTokenPagination; SCIM
Users/Groups/ServicePrincipals (and Account* variants) -> newOffsetPagination.

Signed-off-by: Hector Castejon Diaz <hector.castejon@databricks.com>
@hectorcast-db hectorcast-db added this pull request to the merge queue Jun 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Jun 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 818
  • Commit SHA: 65a8cf0d4435adc129c0a968d1589d233d47bc42

Checks will be approved automatically on success.

@hectorcast-db hectorcast-db added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit b27860a Jun 4, 2026
17 checks passed
@hectorcast-db hectorcast-db deleted the deco-27280-paginator-empty-page branch June 4, 2026 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants