Continue cursor pagination until results are empty#3474
Open
Continue cursor pagination until results are empty#3474
Conversation
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>
If the response omits the next-cursor field (or returns it empty/null), there is no way to fetch a further page, so the loop should terminate even when the current page still has results. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 asynccall_api_paginatedimplementations. 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 onlen(results) == 0, others keep the existinglen(results) < limit_valuecheck.Review checklist
Please check relevant items below: