Skip to content

fix(webhook): resolve fork pull requests for check runs by head SHA - #3428

Merged
integry merged 1 commit into
mainfrom
fix/fork-pr-check-run-lookup
Nov 9, 2026
Merged

integry merged 1 commit into
mainfrom
fix/fork-pr-check-run-lookup

Conversation

@integry

@integry integry commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Problem

PR #3423 (a fork PR from bharveyos/propr) had its lint check fail, yet no failed-CI follow-up comment was posted even though autoFollowupOnFailedCi is on for this repository.

GitHub delivers the check runs of a fork pull request with an empty pull_requests array, and GET /repos/{owner}/{repo}/commits/{sha}/pulls returns nothing for a fork head commit (verified against the open PRs here: same-repo PRs #3427 and #3420 resolve, fork PRs #3423 and #3421 return []). resolveTargetPRs therefore found no PR and the handler took the debug-level check_run skipped: no associated PRs branch. The same gap silently skipped the Ultrafix check hook and auto-merge for fork PRs.

The workflow-side "Report Build Failure" / "Report Full Test Failure" jobs are deliberately skipped for fork PRs (read-only token), so the daemon lookup was the only path, and it did not work.

Fix

When the commit lists no open pull request, scan the repository's open pull requests (most recently updated first, pages of 100, bounded by OPEN_PRS_HEAD_LOOKUP_MAX_PAGES) for one whose head.sha matches the check run's head_sha. The result goes through the existing commit → PR cache, so a default-branch push (which legitimately has no PR) pays the extra listing once per cached lookup.

Also corrects the follow-up docs, which claimed fork check runs were already matched by commit.

Tests

  • test/checkRunHandler.test.ts: fork PR resolved by head SHA for a failed check run; the no-PR case now also scans open PRs; paging stops at a short page; the scan is bounded; found PRs are cached with the positive TTL.
  • Ran test/checkRunHandler.test.ts (125 pass), test/ultrafixRecoveryIntake.test.ts and test/ciFailureRecovery.test.ts (13 pass); eslint --max-warnings 0 on the changed source is clean.

🤖 Generated with Claude Code

GitHub delivers the check runs of a fork pull request with an empty
pull_requests array, and GET /commits/{sha}/pulls lists no pull request
for the fork's head commit in the base repository. The commit lookup
therefore found no PR, so failed-CI follow-ups, the Ultrafix check hook
and auto-merge were never evaluated for fork PRs (#3423:
a failed lint check produced no follow-up comment).

When the commit lists no open PR, scan the repository's open pull
requests for a matching head SHA (pages of 100, bounded). Results are
cached as before, so a default-branch push pays the listing once per
cached lookup.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@integry integry added the AI label Nov 9, 2026
@integry

integry commented Nov 9, 2026

Copy link
Copy Markdown
Owner Author

/review

@propr-dev

propr-dev Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

✅ AI Code Review Complete requested by @integry

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR addresses missing fork-PR resolution with a bounded open-PR scan and reuses the existing lookup cache. It is merge-ready within scope, conditional on pending checks completing successfully.

✅ Bounded lookup — Scans at most five pages of 100 PRs, matches head SHAs case-insensitively, and stops on a short page.

✅ Preserved cache behavior — Fallback matches receive the positive cache TTL; request failures propagate to existing error handling without caching an empty result.

This review is based on the supplied code and context; no commands or tests were run. Current checks show no failures and seven pending.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

S1: 🟢 Test successful follow-up dispatch

In test/checkRunHandler.test.ts, the new fork-resolution handler test returns newer-sha for the current PR head, intentionally reaching the stale-head skip. Add a companion test with a matching current head and assert that failed-CI follow-up is dispatched for PR 55. This would strengthen coverage of the original user-visible problem; the supplied control flow already supports that behavior.

S2: 🟢 Document the scan limit

The updated docs/docs/features/pr-followup.md describes fork support without mentioning the lookup bound. Consider noting that fallback resolution examines the 500 most recently updated open PRs. This optional clarification would make the documentation more precise for large repositories.

Score

The implementation is focused, preserves existing failure handling, and covers pagination and cache TTL behavior. No merge-blocking defect was identified; final readiness remains conditional on pending checks.
Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 24s
  • Tokens: 42,766 (42,316 in / 450 out)
  • Cost: $0.34

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix S1 S2

🤖 Review by ProPR

@integry
integry merged commit 190dae8 into main Nov 9, 2026
47 checks passed
@integry
integry deleted the fix/fork-pr-check-run-lookup branch November 9, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants