feat(integrations): Add paginated repo fetching for GitHub integration#112426
Closed
feat(integrations): Add paginated repo fetching for GitHub integration#112426
Conversation
src/sentry/integrations/api/endpoints/organization_integration_repos.py
Outdated
Show resolved
Hide resolved
1e5937d to
fce1f2e
Compare
fce1f2e to
ae08ef3
Compare
src/sentry/integrations/api/endpoints/organization_integration_repos.py
Outdated
Show resolved
Hide resolved
ae08ef3 to
8fc7ad5
Compare
8fc7ad5 to
abe3be7
Compare
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
abe3be7 to
c135b8f
Compare
…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.
src/sentry/integrations/api/endpoints/organization_integration_repos.py
Outdated
Show resolved
Hide resolved
…nError Passing per_page=0 caused ZeroDivisionError on the page_number calculation. Add max(1, ...) lower bound to the existing upper-bound clamp.
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.
Add opt-in cursor-based pagination to the integration repos endpoint, scoped to GitHub only.
When
paginate=trueis passed (and no search query), the endpoint callsget_repositories_pagewhich fetches a single page from GitHub's/installation/repositoriesAPI 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=truequery param.get_repositories_pageis defined onBaseRepositoryIntegrationwith a defaultreturn None(not supported), and overridden byGitHubIntegrationto fetch a single page. The endpoint calls it and falls through to the non-paginated path ifNoneis 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 sendpaginateand are unaffected.Default page size is 25 repos per page. The
per_pagequery 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