-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Bug: Action fails to find PRs from forks when using pull_request_target
Description
When this action is used with the pull_request_target event for PRs from forks, it fails with a "Not Found" error (HTTP 422).
Root Cause
The issue is in src/adapter/get-prs-associated-with-commit.ts:
const owner = triggeredFromPR
? github.context.payload.pull_request?.head.repo.owner.login // ❌ Fork owner
: github.context.repo.owner
const repo = triggeredFromPR
? github.context.payload.pull_request?.head.repo.name // ❌ Fork repo
: github.context.repo.repoWhen a PR is created from a fork:
- The PR exists in the base repository (where it will be merged)
- The commit exists in the fork repository (the contributor's fork)
head.repopoints to the forkbase.repopoints to the base repository
The action queries the fork repository for PRs associated with the commit, but PRs don't exist in the fork—they exist in the base repository.
Expected Behavior
The action should query the base repository where the PR actually exists.
Fix
Change to use base.repo instead of head.repo:
const owner = triggeredFromPR
? github.context.payload.pull_request?.base.repo.owner.login // ✅ Base owner
: github.context.repo.owner
const repo = triggeredFromPR
? github.context.payload.pull_request?.base.repo.name // ✅ Base repo
: github.context.repo.repoReproduction
- Create a fork of a repository
- Create a PR from the fork to the base repository
- Use this action with
pull_request_targetevent - Observe the "Not Found" error
Environment
- Action version: v4.0.0 (commit: 4056877)
- Event:
pull_request_target - Fork: Yes
I'd be happy to submit a PR with the fix if you'd like!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels