Skip to content

ci: look up fork PRs via the head repository in type-diff-comment - #410

Merged
TooTallNate merged 1 commit into
mainfrom
type-diff-fork-pr-lookup
Jul 6, 2026
Merged

ci: look up fork PRs via the head repository in type-diff-comment#410
TooTallNate merged 1 commit into
mainfrom
type-diff-fork-pr-lookup

Conversation

@TooTallNate

Copy link
Copy Markdown
Owner

Follow-up to #409. The first live fork-PR run (on #404, after syncing it with main) failed in the comment workflow with:

##[error]Unable to resolve PR for head SHA f63803413b82214531c93033fefe60ebcc376ae9

Root cause: listPullRequestsAssociatedWithCommit returns an empty list when the base repo is queried with a commit that only exists in a fork — verified directly:

So the fallback failed for exactly the fork PRs this workflow exists to serve (same-repo PRs never reach the fallback, since workflow_run.pull_requests is populated for them).

Fix

Query the workflow_run.head_repository (the fork) for the commit→PR association, and filter results to PRs that:

  • target this repo (base.repo.full_name match), and
  • have the run's exact head SHA (head.sha or merge_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.

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).
Copilot AI review requested due to automatic review settings July 6, 2026 08:12
@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nx-js Ready Ready Preview, Comment Jul 6, 2026 8:13am

@changeset-bot

changeset-bot Bot commented Jul 6, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 70c2f1a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📝 Runtime Type Changes

✅ No changes to the public TypeScript API surface.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.listPullRequestsAssociatedWithCommit against workflow_run.head_repository instead 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 (or merge_commit_sha).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@TooTallNate
TooTallNate merged commit 55b7cf3 into main Jul 6, 2026
8 checks passed
@TooTallNate
TooTallNate deleted the type-diff-fork-pr-lookup branch July 6, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants