Skip to content

Commit a8e0cfa

Browse files
authored
Early exit when summarize-checks hits an erroneously large # of checks on a given commit SHA (#36389)
1 parent c2affe0 commit a8e0cfa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/src/summarize-checks/summarize-checks.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,26 @@ export function updateLabels(existingLabels, impactAssessment) {
592592
* @returns {Promise<any>} Complete GraphQL response with all check suites
593593
*/
594594
async function getAllCheckSuites(github, core, owner, repo, sha, prNumber) {
595+
// First, get the total count using REST API to avoid expensive GraphQL if there are too many suites
596+
const { data: checkSuitesResponse } = await github.rest.checks.listSuitesForRef({
597+
owner,
598+
repo,
599+
ref: sha,
600+
per_page: 1, // We only need the count, not the actual data
601+
});
602+
603+
const totalCheckSuites = checkSuitesResponse.total_count;
604+
605+
// Bail if too many check suites to avoid burning GraphQL rate limits
606+
if (totalCheckSuites > 500) {
607+
throw new Error(
608+
`Too many check suites (${totalCheckSuites}) for ${owner}/${repo}#${prNumber}@${sha}. Summarize-Checks ending with error to avoid exhausting graphQL resources.`,
609+
);
610+
} else {
611+
core.info(`Found ${totalCheckSuites} total check suites`);
612+
}
613+
614+
// Now proceed with GraphQL pagination
595615
const resourceUrl = `https://github.com/${owner}/${repo}/commit/${sha}`;
596616
let allCheckSuites = [];
597617
let hasNextPage = true;

0 commit comments

Comments
 (0)