-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already existsp1Showstopper bug preventing substantial subset of users from using the product, or incorrect docsShowstopper bug preventing substantial subset of users from using the product, or incorrect docs
Description
Bug: Fork PRs fail with "couldn't find remote ref" - branch.ts doesn't use refs/pull/*/head
Description
The action fails on PRs from forks with:
Prepare step failed with error: Command failed: git fetch origin --depth=20 <branch-name>
fatal: couldn't find remote ref <branch-name>
This affects both pull_request_target and issue_comment triggers.
Root Cause
In src/github/operations/branch.ts, the action fetches branches by name from origin:
const branchName = prData.headRefName;
execGit(["fetch", "origin", `--depth=${fetchDepth}`, branchName]);For fork PRs, the branch doesn't exist on origin — it exists in the fork's repo. The code should use GitHub's PR refs instead:
// For fork PRs, use PR ref instead of branch name
const ref = isFork ? `refs/pull/${prNumber}/head` : branchName;
execGit(["fetch", "origin", `--depth=${fetchDepth}`, ref]);Related Issues
- Claude Code Action fails with "couldn't find remote ref" error for PRs from forks #223 - Same error, open since July 2025
- Claude review fails on PRs from forks #339 - Fork PR OIDC issues (different root cause but same symptom)
- Comments in (forked) PR trigger claude-code-action with wrong branch #46 - issue_comment triggers wrong branch for forks
Environment
- Action version: v1 (v1.0.29)
- Trigger:
issue_commenton a PR from a fork - Workflow correctly checks out the PR via
gh pr checkoutbefore the action runs, but the action's internal fetch still fails
Expected Behavior
Fork PRs should work the same as same-repo PRs. The action should detect fork PRs and use refs/pull/{number}/head for fetching.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingduplicateThis issue or pull request already existsThis issue or pull request already existsp1Showstopper bug preventing substantial subset of users from using the product, or incorrect docsShowstopper bug preventing substantial subset of users from using the product, or incorrect docs