Skip to content

Commit 164e6c6

Browse files
committed
fix(integrations): Clamp per_page minimum to 1 to prevent ZeroDivisionError
Passing per_page=0 caused ZeroDivisionError on the page_number calculation. Add max(1, ...) lower bound to the existing upper-bound clamp.
1 parent d58dec5 commit 164e6c6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def _get_paginated_repos(
102102
cursor_param = request.GET.get("cursor")
103103
try:
104104
cursor = Cursor.from_string(cursor_param) if cursor_param else Cursor(0, 0, False)
105-
per_page = min(int(request.GET.get("per_page", 100)), 100)
105+
per_page = max(1, min(int(request.GET.get("per_page", 100)), 100))
106106
except (ValueError, TypeError):
107107
return self.respond({"detail": "Invalid cursor or per_page parameter."}, status=400)
108108
page_number = (cursor.offset // per_page) + 1

0 commit comments

Comments
 (0)