Fix misleading fork detection for issue_comment and other minimal-PR events#26144
Merged
Fix misleading fork detection for issue_comment and other minimal-PR events#26144
Conversation
For non-pull_request events (e.g. issue_comment), the event payload
only contains a minimal PR object ({number, state}) without head/base
data. Previously, detectForkPR was called on this minimal object,
which incorrectly reported 'head repository deleted (was likely a fork)'
and emitted a misleading fork warning.
Now:
- logPRContext reports fork status as 'unknown' when head data is missing
- fetchPRDetails returns the full PR object from the API
- Fork detection runs on the full API data in the else branch
- Fork warning is only emitted when fork status is truly confirmed
Also uses strict isFork === false check for the fast path to avoid
treating null (unknown) as non-fork.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes misleading fork detection for minimal PR payload events (e.g., issue_comment) by treating fork status as unknown until full PR details are fetched from the GitHub API.
Changes:
- Update
logPRContextto avoid calling fork detection when PR payload lacks full details, logging fork status as unknown. - Extend
fetchPRDetailsto return the full PR object along withcommitCount/headRef, and re-resolve fork status from API data. - Add/adjust tests to cover minimal-PR payload scenarios and update mocks to include
head/baserepo data.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/checkout_pr_branch.cjs | Defers fork detection for minimal PR payloads and re-evaluates fork status from API-fetched full PR data. |
| actions/setup/js/checkout_pr_branch.test.cjs | Adds coverage for minimal PR payload events and updates mocks to match new API data expectations. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
For non-
pull_requestevents (e.g.issue_comment,pull_request_review), the event payload only contains a minimal PR object ({number, state}) withouthead/basedata.detectForkPR()was called on this minimal object, which incorrectly reported"head repository deleted (was likely a fork)"and emitted a misleading fork warning (⚠️ Fork PR detected).Solution
logPRContext: Reports fork status as"unknown"whenpullRequest.headis missing, instead of callingdetectForkPRon incomplete datafetchPRDetails: Now returns the full PR object alongsidecommitCount/headRefmain()else branch: Fetches full PR data first, then resolves fork status accurately usingdetectForkPR(fullPR)— logs"Is fork PR (from API): ..."when resolvedTests
issue_commentwithpayload.issue.pull_request)