ci: look up fork PRs via the head repository in type-diff-comment - #410
Conversation
listPullRequestsAssociatedWithCommit returns nothing when the base repo is queried with a commit that only exists in a fork, so the PR resolution failed for exactly the fork PRs this workflow exists to serve (observed on #404: 'Unable to resolve PR for head SHA'). Query the workflow_run's head_repository instead, and filter the results to PRs that target this repo with the run's exact head SHA (the PR association returned by the API is authoritative, so a fork cannot spoof it).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
📝 Runtime Type Changes✅ No changes to the public TypeScript API surface. |
There was a problem hiding this comment.
Pull request overview
Fixes fork-PR support in the “Type Diff Comment” workflow by resolving the pull request via the workflow run’s head_repository (the fork) when workflow_run.pull_requests is empty. This aligns with how GitHub’s commit→PR association API behaves for commits that only exist in a fork.
Changes:
- Query
repos.listPullRequestsAssociatedWithCommitagainstworkflow_run.head_repositoryinstead of the base repo when resolving the PR number. - Filter associated PRs to those targeting the base repo and matching the run’s exact
head_sha(ormerge_commit_sha).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Follow-up to #409. The first live fork-PR run (on #404, after syncing it with main) failed in the comment workflow with:
Root cause:
listPullRequestsAssociatedWithCommitreturns an empty list when the base repo is queried with a commit that only exists in a fork — verified directly:GET /repos/TooTallNate/nx.js/commits/f638034.../pulls→[]GET /repos/natureglass/nx.js_extended/commits/f638034.../pulls→ PR runtime: defer scheme resolution to globalThis.fetch in Image/Audio/Video #404So the fallback failed for exactly the fork PRs this workflow exists to serve (same-repo PRs never reach the fallback, since
workflow_run.pull_requestsis populated for them).Fix
Query the
workflow_run.head_repository(the fork) for the commit→PR association, and filter results to PRs that:base.repo.full_namematch), andhead.shaormerge_commit_sha)The association data comes from GitHub's API and is authoritative — a fork cannot fabricate a PR association pointing at an arbitrary PR, so the comment-targeting security property from #409 is preserved.
After merging, re-running the "Type Diff" check on #404 will trigger a fresh comment run using this fixed workflow.