Skip to content

[Bug]: PR details fail to load for fork repositories — getOwnerRepo only checks origin #7331

Closed

Description

@fsdwen

Bug Report

Summary

When viewing a PR in a fork repository (where origin points to the fork and upstream points to the original repo), the PR details dialog shows "Unable to load details for this GitHub item."

Root Cause

getOwnerRepo() in src/main/github/github-repository-identity.ts:206 only checks the origin remote:

export async function getOwnerRepo(...): Promise<OwnerRepo | null> {
  return getOwnerRepoForRemote(repoPath, "origin", ...)  // only origin
}

But getIssueOwnerRepo() at line 214 correctly checks upstream first, then falls back to origin:

export async function getIssueOwnerRepo(...): Promise<OwnerRepo | null> {
  const upstream = await getOwnerRepoForRemote(repoPath, "upstream", ...)
  if (upstream) return upstream
  return getOwnerRepoForRemote(repoPath, "origin", ...)  // fallback
}

The code comment in client.ts:1900 even acknowledges this discrepancy:

"the issue lookup now targets upstream while the PR lookup targets origin"

Steps to Reproduce

  1. Have a repo where origin → fork, upstream → original repo
  2. Open a PR from the PR list in Orca
  3. See "Unable to load details for this GitHub item."

Actual Behavior

# What Orca does:
gh pr view 7221 --repo fsdwen/orca --json ...
# → Could not resolve to a PullRequest with the number of 7221.

# What it should do:
gh pr view 7221 --repo stablyai/orca --json ...
# → Successfully returns PR data

Expected Behavior

PR details should load correctly regardless of whether the repo is a fork, just as issue details already do.

Impact

All Orca users working with fork repositories cannot view PR details.

Proposed Fix

Change getOwnerRepo() to check upstream first, matching the behavior of getIssueOwnerRepo().

Activity

  1. added theissue type on Jul 12, 2026
  2. added
    bug
    on Jul 16, 2026
  3. nwparker commented on Jul 18, 2026

    @nwparker
    Contributor

    Status: REPRODUCED (unit test)

    Confirmed in the current tree. getOwnerRepo() in src/main/github/github-repository-identity.ts:206 resolves the repo from the origin remote only, whereas getIssueOwnerRepo() at line 214 checks upstream first. On a fork checkout (origin→fork, upstream→parent), the PR-detail paths in client.ts (the gh pr view callers that fall back to getOwnerRepo, e.g. lines 3613/3886/3979/4119/…) target the fork, so gh pr view <N> --repo <fork> fails with "Could not resolve to a PullRequest" — surfaced as "Unable to load details for this GitHub item." Issue details work precisely because their resolver already prefers upstream.

    Repro test imports the real module and mocks the git runner (origin→fsdwen/orca, upstream→stablyai/orca): getOwnerRepo() returns the fork, getIssueOwnerRepo() returns the parent — the exact divergence reported.

    Re-run:

    pnpm exec vitest run --config config/vitest.config.ts src/main/github/repro-7331-fork-pr-owner-repo.test.ts
    

    Fix direction: make getOwnerRepo() prefer upstream then fall back to origin (mirroring getIssueOwnerRepo), or route PR-detail lookups through the existing resolvePRRepositoryCandidates(). Preserve fork-push semantics where the fork is the correct head repo for PR creation.

    Key files: src/main/github/github-repository-identity.ts, src/main/github/client.ts


    Automated bug-reproduction pass. Repro artifact committed on branch nwparker/bug-repro-pass2; check it out to run the command above. Writeup: docs/bug-reproductions/7331.md.

  4. added
    has_repro
    on Jul 18, 2026
  5. added a commit that references this issue on Oct 15, 2026
    e1d5445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughas_repro

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions