Summary
NextCursorPage can carry an explicit server-provided next cursor, but both GetNextPage() and the auto-pager currently stop as soon as the current page has an empty data array.
That means an empty first or intermediate page silently terminates iteration even when has_more is true and next points to a later page containing results.
This is observable through public endpoints using NextCursorPage, including Admin.Organization.Groups.ListAutoPaging.
Reproduction
Using a custom HTTP client, return these pages from Admin.Organization.Groups.ListAutoPaging:
GET /organization/groups
{"data":[],"has_more":true,"next":"cursor-1"}
GET /organization/groups?after=cursor-1
{"data":[{"id":"group-1","created_at":1,"group_type":"group","is_scim_managed":false,"name":"one"}],"has_more":false,"next":null}
On current main, auto-pagination yields no groups and makes only the first request.
The same happens for an empty intermediate page:
page 1: data=[group-1], next=cursor-1
page 2: data=[], next=cursor-2
page 3: data=[group-2], terminal
Current result is only group-1; page 3 is never requested.
Root cause
NextCursorPage.GetNextPage() returns early on len(r.Data) == 0 before consulting HasMore or Next, and NextCursorPageAutoPager.Next() has the same empty-data termination check.
For explicit-next pagination, the continuation token is the pagination authority. An empty result page does not necessarily mean there is no next page.
Expected behavior
NextCursorPage auto-pagination should follow a non-empty next cursor through empty first or intermediate pages. It should still stop normally when has_more is explicitly false or when no next cursor is provided.
Ordinary populated-page behavior should remain unchanged.
Summary
NextCursorPagecan carry an explicit server-providednextcursor, but bothGetNextPage()and the auto-pager currently stop as soon as the current page has an emptydataarray.That means an empty first or intermediate page silently terminates iteration even when
has_moreis true andnextpoints to a later page containing results.This is observable through public endpoints using
NextCursorPage, includingAdmin.Organization.Groups.ListAutoPaging.Reproduction
Using a custom HTTP client, return these pages from
Admin.Organization.Groups.ListAutoPaging:On current
main, auto-pagination yields no groups and makes only the first request.The same happens for an empty intermediate page:
Current result is only
group-1; page 3 is never requested.Root cause
NextCursorPage.GetNextPage()returns early onlen(r.Data) == 0before consultingHasMoreorNext, andNextCursorPageAutoPager.Next()has the same empty-data termination check.For explicit-next pagination, the continuation token is the pagination authority. An empty result page does not necessarily mean there is no next page.
Expected behavior
NextCursorPageauto-pagination should follow a non-emptynextcursor through empty first or intermediate pages. It should still stop normally whenhas_moreis explicitly false or when no next cursor is provided.Ordinary populated-page behavior should remain unchanged.