From abe47e845e03bd6f153218a25ffb653856763828 Mon Sep 17 00:00:00 2001 From: Otto-AGPT Date: Fri, 6 Feb 2026 19:22:21 +0000 Subject: [PATCH] fix: add pagination for PRs and comments Addresses review feedback: - Use github.paginate() for pulls.list to handle >100 open PRs - Use github.paginate() for issues.listComments to handle >100 comments - Prevents missing PRs in scheduled sweeps - Prevents duplicate reminder comments on busy PRs --- .github/workflows/cla-label-sync.yml | 39 ++++++++++++++++------------ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cla-label-sync.yml b/.github/workflows/cla-label-sync.yml index 1dfb4e9a44..c9d56ab5ae 100644 --- a/.github/workflows/cla-label-sync.yml +++ b/.github/workflows/cla-label-sync.yml @@ -126,18 +126,22 @@ jobs: return { found: false, passed: false, state: 'unknown' }; } - // Helper: Check if bot already commented with a specific marker + // Helper: Check if bot already commented with a specific marker (paginated) async function hasCommentWithMarker(prNumber, marker) { - const { data: comments } = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: prNumber, - per_page: 100 - }); + // Use paginate to fetch ALL comments, not just first 100 + const comments = await github.paginate( + github.rest.issues.listComments, + { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + per_page: 100 + } + ); return comments.some(c => - c.user.type === 'Bot' && - c.body.includes(marker) + c.user?.type === 'Bot' && + c.body?.includes(marker) ); } @@ -167,13 +171,16 @@ jobs: prsToCheck = [parseInt(context.payload.inputs.pr_number)]; } else { - // Scheduled run: check all open PRs - const { data: openPRs } = await github.rest.pulls.list({ - owner: context.repo.owner, - repo: context.repo.repo, - state: 'open', - per_page: 100 - }); + // Scheduled run: check all open PRs (paginated to handle >100 PRs) + const openPRs = await github.paginate( + github.rest.pulls.list, + { + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + per_page: 100 + } + ); prsToCheck = openPRs.map(pr => pr.number); }