Skip to content

feat(integrations): Add paginated repo fetching for GitHub integration#112426

Closed
jaydgoss wants to merge 4 commits intomasterfrom
jaygoss/vdy-46-scm-repo-pagination-be
Closed

feat(integrations): Add paginated repo fetching for GitHub integration#112426
jaydgoss wants to merge 4 commits intomasterfrom
jaygoss/vdy-46-scm-repo-pagination-be

Conversation

@jaydgoss
Copy link
Copy Markdown
Member

@jaydgoss jaydgoss commented Apr 7, 2026

Add opt-in cursor-based pagination to the integration repos endpoint, scoped to GitHub only.

When paginate=true is passed (and no search query), the endpoint calls get_repositories_page which fetches a single page from GitHub's /installation/repositories API and returns standard Sentry cursor pagination headers. This avoids aggregating all GitHub pages into one response, which is slow for large installations.

The paginated path is opt-in via a paginate=true query param. get_repositories_page is defined on BaseRepositoryIntegration with a default return None (not supported), and overridden by GitHubIntegration to fetch a single page. The endpoint calls it and falls through to the non-paginated path if None is returned, so all other integrations are unaffected.

All existing callers get unchanged behavior -- the three other frontend consumers of this endpoint (integrationReposAddRepository, repositoryProjectPathConfigForm, useScmIntegrationTreeData) do not send paginate and are unaffected.

Default page size is 25 repos per page. The per_page query param allows callers to override up to a max of 100.

PR 1 of 2 -- this is the backend. The frontend PR that consumes this: #112427

Refs VDY-46

@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 7, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 7, 2026
Add opt-in cursor-based pagination to the integration repos endpoint, scoped to GitHub only.

When `paginate=true` is passed (and no search query), the endpoint calls `get_repositories_page` which fetches a single page from GitHub's `/installation/repositories` API and returns standard Sentry cursor pagination headers. This avoids aggregating all GitHub pages into one response, which is slow for large installations.

The paginated path is gated behind `paginate=true` and duck-typed via `hasattr(install, "get_repositories_page")`, so only GitHub is affected. All existing callers get unchanged behavior.

Also extracts `_format_repos` to share repo formatting between `get_repositories` and `get_repositories_page`, and `_serialize_repos` to share serialization in the endpoint.

Default page size is 25. The `per_page` query param allows callers to override up to 100.

Refs VDY-46
…ing to 100

Align with the existing BaseApiClient.page_size default. 25 was
unnecessarily small for a repo selector, causing extra round-trips
through Sentry and GitHub for most users.
…nError

Passing per_page=0 caused ZeroDivisionError on the page_number
calculation. Add max(1, ...) lower bound to the existing upper-bound
clamp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant