Skip to content

internal/extsvc/github: Fix pagination in ListOrganizations

Administrator requested to merge ig/github-list-orgs-pagination into main

Created by: indradhanush

The GitHub API does not use per_page for pagination of the /organizations API contrary to expectation based on existing APIs. It uses since to return orgs with ID greater than this value. Therefore this:

GET /organizations

is the same as:

GET /organizations?since=0

If the list of orgs here returned contains 100 items with the IDs being 1 to 100 (not guaranteed if an org is deleted), the next page will need to be requested as:

GET /organizations?since=100

Which would then return orgs starting with ID 101 and all the way upto 200 provided that no org was deleted. If any orgs were deleted, the list would still contain 100 orgs with their IDs in ascending order, but they might not be increasing monotonically.

Test plan

  • Modified existing tests to make them pass
  • Added more integration and mock tests

Merge request reports

Loading