Skip to content

Commit 0bce46d

Browse files
committed
ref(github): Address review nits on paginated repos
Document cache consistency caveat in get_repositories_paginated docstring: cache expiry between pages can cause duplicates/skips, acceptable for infinite-scroll. Make _parse_cursor a staticmethod. Add comment clarifying per_page and offset are guaranteed set when paginated is not None. Refs VDY-46
1 parent 50e1bd8 commit 0bce46d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/sentry/integrations/api/endpoints/organization_integration_repos.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ def get(
129129
{"repos": serialized_repositories, "searchable": install.repo_search}
130130
)
131131

132+
# per_page and offset are guaranteed set when paginated is not None
132133
if paginated is not None and (has_next or offset > 0):
133134
# CursorResult only used for Link header generation
134135
cursor_result: CursorResult[IntegrationRepository] = CursorResult(
@@ -142,7 +143,8 @@ def get(
142143

143144
return self.respond({"detail": "Repositories not supported"}, status=400)
144145

145-
def _parse_cursor(self, request: Request) -> Cursor:
146+
@staticmethod
147+
def _parse_cursor(request: Request) -> Cursor:
146148
cursor_param = request.GET.get("cursor", "")
147149
if not cursor_param:
148150
return Cursor(0, 0, False)

src/sentry/integrations/github/integration.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,10 @@ def get_repositories_paginated(
379379
"""Paginate over the cached accessible-repos list.
380380
381381
Always serves from ``get_accessible_repos_cached()`` so every
382-
page is fast after the initial cache warm-up.
382+
page is fast after the initial cache warm-up. If the cache
383+
expires between page fetches the underlying list can change,
384+
which may cause duplicates or skipped repos across pages.
385+
This is acceptable for infinite-scroll consumers.
383386
"""
384387
client = self.get_client()
385388
all_repos = client.get_accessible_repos_cached()

0 commit comments

Comments
 (0)