@@ -80,31 +80,22 @@ export default function crcrOncallBot(app: Probot): void {
8080 }
8181
8282 // Get the PRs this check run belongs to.
83+ // checkRun.pull_requests is empty for cross-fork PRs (most pytorch
84+ // contributions), so fall back to extracting the PR number from the
85+ // check run's output.summary, which the Lambda side embeds in the format
86+ // "{downstream_repo} workflow for PR {pr_number}: {details_url}".
87+ // If neither yields a PR, fall back to the Search API as a last resort.
88+ // The commits-pulls API (listPullRequestsAssociatedWithCommit) also returns
89+ // empty for cross-fork PRs on large repos like pytorch/pytorch, but the
90+ // Search API indexes commits across forks and reliably finds them.
8391 let prNumbers : number [ ] = [ ] ;
84- if ( checkRun . output ?. summary ) {
92+ if ( checkRun . pull_requests && checkRun . pull_requests . length > 0 ) {
93+ prNumbers = checkRun . pull_requests . map ( ( pr ) => pr . number ) ;
94+ } else if ( checkRun . output ?. summary ) {
8595 const match = checkRun . output . summary . match ( / f o r P R ( \d + ) / ) ;
8696 if ( match ) {
8797 prNumbers = [ parseInt ( match [ 1 ] , 10 ) ] ;
8898 }
89- } else if ( checkRun . pull_requests && checkRun . pull_requests . length > 0 ) {
90- prNumbers = checkRun . pull_requests . map ( ( pr ) => pr . number ) ;
91- }
92-
93- // Fall back to Search API if still no PR found (e.g., pr_number was empty
94- // on the Lambda side).
95- if ( prNumbers . length === 0 && checkRun . head_sha ) {
96- try {
97- const result = await ctx . octokit . rest . search . issuesAndPullRequests ( {
98- q : `${ checkRun . head_sha } type:pr repo:${ owner } /${ repo } ` ,
99- } ) ;
100- prNumbers = result . data . items . map ( ( item : any ) => item . number ) ;
101- } catch ( err ) {
102- ctx . log (
103- { err } ,
104- `crcrOncall: failed to resolve PRs for commit ${ checkRun . head_sha } , skipping`
105- ) ;
106- return ;
107- }
10899 }
109100
110101 if ( prNumbers . length === 0 ) {
0 commit comments