Skip to content

Continue cursor pagination until results are empty#3474

Open
nogates wants to merge 1 commit intomasterfrom
nogates/cursor-paginate-empty
Open

Continue cursor pagination until results are empty#3474
nogates wants to merge 1 commit intomasterfrom
nogates/cursor-paginate-empty

Conversation

@nogates
Copy link
Copy Markdown
Contributor

@nogates nogates commented May 4, 2026

What does this PR do?

Mirrors DataDog/datadog-api-client-go#3769 for the Python client. When an endpoint uses cursor-based pagination, the loop now keeps requesting pages until the server returns an empty result set, instead of stopping at the first page smaller than the requested limit. Behavior for offset/page-based pagination is unchanged.

The change is applied in both the Jinja template (api_client.j2) and the generated runtime helper (api_client.py), in both the sync and async call_api_paginated implementations. Pagination test cassettes already include the trailing empty-page response (regenerated previously in commit 1588b58), so no cassette work was needed.

(Replaces #3473, which was auto-closed during a branch rename.)

Additional Notes

The break condition now branches on whether the pagination dict carries cursor_param: cursor pagination breaks on len(results) == 0, others keep the existing len(results) < limit_value check.

Review checklist

Please check relevant items below:

  • This PR includes all newly recorded cassettes for any modified tests.
  • This PR does not rely on API client schema changes.
    • The CI should be fully passing.
  • Or, this PR relies on API schema changes and this is a Draft PR to include tests for that new functionality.

Mirror DataDog/datadog-api-client-go#3769: when an endpoint uses cursor-based pagination, keep requesting pages until the server returns an empty result set instead of stopping at the first page smaller than the requested limit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@nogates nogates requested review from a team as code owners May 4, 2026 09:09
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.

1 participant