Skip to content

Commit 9582f85

Browse files
fix(backend): stop Gitea/Forgejo pagination on empty page response
When an API token can only see a subset of org repos, the x-total-count header reports the org total while the token returns fewer items. The previous loop condition (output.length < totalCount) would never be satisfied for the visible subset, causing infinite pagination. Now we break out of the loop when the API returns an empty page, matching the Gitea API pagination docs recommendation. Fixes #1108 Co-authored-by: Brendan Kellam <brendan-kellam@users.noreply.github.com>
1 parent 06c379a commit 9582f85

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

packages/backend/src/gitea.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ const paginate = async <T>(request: (page: number) => Promise<HttpResponse<T[],
254254
while (output.length < totalCount) {
255255
page++;
256256
const result = await request(page);
257+
if (result.data.length === 0) {
258+
break;
259+
}
257260
output.push(...result.data);
258261
}
259262

0 commit comments

Comments
 (0)