Skip to content

Commit 5e1a2f0

Browse files
xwang233claude
andcommitted
Fix critical GitHub API pagination bugs in auto-merge workflow
This fixes a severe bug where the auto-merge workflow only checked the first 30 commit statuses, causing it to miss failures and incorrectly merge PRs with failing checks. Root cause analysis: - PR #5578 had 2 failed GB200 tests at 23:23-23:25 UTC - By 03:29 UTC, 27+ new successful statuses pushed failures past position 30 - Workflow only fetched first page (30 items), saw 0 failures, and merged Fixed 4 critical pagination issues: 1. listCommitStatusesForRef (line 140) - CRITICAL: Only saw 30 of 57 statuses 2. checks.listForRef (line 173) - Could miss failed checks if >30 exist 3. issues.listComments (line 349) - Wouldn't find status comment if >30 comments 4. pulls.list (line 64) - Could miss PR if >30 open PRs on branch All API calls now use github.paginate() to retrieve complete results. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent abbbf4e commit 5e1a2f0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.github/workflows/auto-merge.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ jobs:
6161
pr = data;
6262
} else {
6363
// For check_run events, we need to find the PR
64-
const prs = await github.rest.pulls.list({
64+
const prsData = await github.paginate(github.rest.pulls.list, {
6565
owner: context.repo.owner,
6666
repo: context.repo.repo,
6767
state: 'open',
6868
head: `${context.repo.owner}:${context.payload.check_run?.head_branch}`,
6969
});
7070
71-
if (prs.data.length === 0) {
71+
if (prsData.length === 0) {
7272
core.info('No open PR found for this commit');
7373
return { should_skip: true };
7474
}
7575
76-
pr = prs.data[0];
76+
pr = prsData[0];
7777
}
7878
7979
// Defensive checks: skip if PR is from a fork
@@ -137,7 +137,7 @@ jobs:
137137
};
138138
139139
// 1. Get all commit statuses (for nvfuser-ci and other status checks)
140-
const { data: statuses } = await github.rest.repos.listCommitStatusesForRef({
140+
const statuses = await github.paginate(github.rest.repos.listCommitStatusesForRef, {
141141
owner: context.repo.owner,
142142
repo: context.repo.repo,
143143
ref: sha,
@@ -170,11 +170,12 @@ jobs:
170170
);
171171
172172
// 2. Get all check runs
173-
const { data: checkRuns } = await github.rest.checks.listForRef({
173+
const checkRunsData = await github.paginate(github.rest.checks.listForRef, {
174174
owner: context.repo.owner,
175175
repo: context.repo.repo,
176176
ref: sha,
177177
});
178+
const checkRuns = { check_runs: checkRunsData };
178179
179180
core.info(`Found ${checkRuns.check_runs.length} check runs`);
180181
@@ -345,7 +346,7 @@ jobs:
345346
const statusText = statusLines.join('\n');
346347
347348
// Find the comment with placeholders
348-
const { data: comments } = await github.rest.issues.listComments({
349+
const comments = await github.paginate(github.rest.issues.listComments, {
349350
owner: context.repo.owner,
350351
repo: context.repo.repo,
351352
issue_number: pr_number,

0 commit comments

Comments
 (0)