Repository navigation
Conversation
📝 WalkthroughWalkthroughChanges
Sequence Diagram(s)See hidden artifact diagram above. Compact metadata
Related issues: None provided Poem 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main/github/client.ts (2)
1872-1913: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
getIssueOwnerReponame no longer reflects its usage.The function is now used to resolve owner/repo for both issue and PR lookups, but its name still implies issue-only scope. This can mislead future maintainers reading
getWorkItemor the function's definition site.Consider renaming it to something scope-neutral (e.g.
getUpstreamFirstOwnerRepoorgetWorkItemOwnerRepo) ingithub-repository-identity.ts, updating the few call sites inclient.tsand the mock inclient.test.ts.
1888-1917: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRedundant
getIssueOwnerReporesolution in the fallback path.When
typeis unspecified,getIssueOwnerRepo(repoPath, connectionId, localGitOptions)is invoked twice with identical arguments (line 1891 and line 1913) — once for the issue attempt, once for the PR fallback. Each call shells out to git to resolve remotes; resolving it once and reusing the result would avoid a duplicate subprocess invocation on this path.♻️ Suggested refactor
try { + const ownerRepo = await getIssueOwnerRepo(repoPath, connectionId, localGitOptions) const issue = await fetchIssueWorkItem( repoPath, - await getIssueOwnerRepo(repoPath, connectionId, localGitOptions), + ownerRepo, number, connectionId, localGitOptions ) if (issue) { return issue } } catch (err) { ... } return await fetchPullRequestWorkItem( repoPath, - await getIssueOwnerRepo(repoPath, connectionId, localGitOptions), + ownerRepo, number, connectionId, localGitOptions )
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7b6cdb33-335a-4bf6-90a8-5ef9af180c82
📥 Commits
Reviewing files that changed from the base of the PR and between 8070e65 and be618d1a05c5ddd567b8177f6ad13ab235cb0bf1.
📒 Files selected for processing (2)
src/main/github/client.test.tssrc/main/github/client.ts
| // Why: both issue and PR lookups now target `upstream`-first (via | ||
| // getIssueOwnerRepo), so a transient upstream failure on issue #N | ||
| // would still fall through to a PR lookup on the same upstream repo. | ||
| // Only fall through when the issue genuinely doesn't exist (404); | ||
| // re-throw everything else so the outer catch returns null and the | ||
| // caller sees a real failure instead of a wrong item. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Comment exceeds the one/two-line guideline.
This "Why" comment spans 6 lines. As per path instructions, **/*.{ts,tsx,js,jsx} files should "Keep comments short — one or two lines, capturing only the non-obvious reason."
✏️ Suggested condensed comment
- // Why: both issue and PR lookups now target `upstream`-first (via
- // getIssueOwnerRepo), so a transient upstream failure on issue `#N`
- // would still fall through to a PR lookup on the same upstream repo.
- // Only fall through when the issue genuinely doesn't exist (404);
- // re-throw everything else so the outer catch returns null and the
- // caller sees a real failure instead of a wrong item.
+ // Why: only fall through to PR lookup on a genuine 404 (issue doesn't
+ // exist); re-throw other errors to avoid masking real failures.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Why: both issue and PR lookups now target `upstream`-first (via | |
| // getIssueOwnerRepo), so a transient upstream failure on issue #N | |
| // would still fall through to a PR lookup on the same upstream repo. | |
| // Only fall through when the issue genuinely doesn't exist (404); | |
| // re-throw everything else so the outer catch returns null and the | |
| // caller sees a real failure instead of a wrong item. | |
| // Why: only fall through to PR lookup on a genuine 404 (issue doesn't | |
| // exist); re-throw other errors to avoid masking real failures. |
Source: Path instructions
getOwnerRepo previously only checked origin, causing all PR operations (viewing, commenting, merging, checks, etc.) to fail in fork repos where the PR actually lives in the upstream canonical repo. Change getOwnerRepo to resolve upstream-first (matching the pre-existing getIssueOwnerRepo behaviour), and add getOriginOwnerRepo for the two callers that specifically need the fork origin remote: - createGitHubPullRequest (head repo is the fork) - getRepoUpstream (fork detection) getIssueOwnerRepo is kept as a backwards-compatible alias. Fixes stablyai#7331 Co-Authored-By: Claude <noreply@anthropic.com>
be618d1 to
62c9b87
Compare
|
@nwparker @AmethystLiang — this fixes a bug where PR details fail to load in fork repos (e.g. origin→fork, upstream→canonical). The root fix changes |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/github/gh-utils.test.ts (1)
146-154: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTest intent is now stale given the delegation refactor.
Since
getIssueOwnerReponow fully delegates togetOwnerRepo(same cache key, same remote-resolution order), this test no longer exercises two distinct code paths — it's effectively calling the same function twice through the same cache entry. The twomockResolvedValueOncevalues remain queued but the second call will likely hit cache and never consume the second mock. Consider renaming/simplifying this test to reflect thatgetIssueOwnerRepois a thin alias ofgetOwnerRepo, or removing it as redundant with the "upstream-first" tests above.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: bfd547ee-f849-4687-a7da-b79c2bb20729
📥 Commits
Reviewing files that changed from the base of the PR and between be618d1a05c5ddd567b8177f6ad13ab235cb0bf1 and 62c9b87.
📒 Files selected for processing (6)
src/main/github/client-create-pr.test.tssrc/main/github/client.test.tssrc/main/github/client.tssrc/main/github/gh-utils.test.tssrc/main/github/gh-utils.tssrc/main/github/github-repository-identity.ts
…#9384) On a fork checkout (origin=fork, upstream=parent) PR details failed to load because getOwnerRepo() resolved only the origin remote while GitHub PRs live on the upstream parent. Make getOwnerRepo() prefer upstream (mirroring getIssueOwnerRepo), and pin the call sites that genuinely need the checkout's own origin identity (getRepoSlug, getRepoUpstream, createGitHubPullRequest, resolvePrWorkItemSource) to the origin-only primitive. Lands the fix community-identified in #7332 and hardened in #7513. Closes #7331 Co-authored-by: fsdwen <1214772+fsdwen@users.noreply.github.com> Co-authored-by: brennanb2025 <79079362+brennanb2025@users.noreply.github.com>
|
Thanks @fsdwen — your root-cause analysis in #7331 and this fix were spot-on. The upstream-first change just landed on main in #9384 (commit 4930c87), which carries the same core fix rebased against current main plus an audit of the newer |
…stablyai#9384) On a fork checkout (origin=fork, upstream=parent) PR details failed to load because getOwnerRepo() resolved only the origin remote while GitHub PRs live on the upstream parent. Make getOwnerRepo() prefer upstream (mirroring getIssueOwnerRepo), and pin the call sites that genuinely need the checkout's own origin identity (getRepoSlug, getRepoUpstream, createGitHubPullRequest, resolvePrWorkItemSource) to the origin-only primitive. Lands the fix community-identified in stablyai#7332 and hardened in stablyai#7513. Closes stablyai#7331 Co-authored-by: fsdwen <1214772+fsdwen@users.noreply.github.com> Co-authored-by: brennanb2025 <79079362+brennanb2025@users.noreply.github.com>
Summary
Fixes #7331 — PR details fail to load for fork repositories.
Root Cause
getOwnerRepo()only checked theoriginremote (the fork), but in fork repos all PR operations — viewing, commenting, merging, checks — operate on the upstream canonical repo where the PR actually lives. This causedgetWorkItem()and all PR detail functions to return null, showing "Unable to load details for this GitHub item."Meanwhile
getIssueOwnerRepo()already had the correct upstream-first-then-origin fallback, which is why issue lookups worked fine in fork repos.Fix
Root fix in
github-repository-identity.ts:getOwnerRepo()now resolves upstream-first (checksupstreamremote, falls back toorigin)getOriginOwnerRepo()for the two callers that explicitly need the fork origingetIssueOwnerRepo()kept as a backwards-compatible aliasCaller updates in
client.ts:createGitHubPullRequest→getOriginOwnerRepo(head repo is the fork)getRepoUpstream→getOriginOwnerRepo(fork detection)Zero changes to
work-item-details.tsand other PR detail functions — all ~10 functions that fetch PR body, comments, files, checks, etc. automatically benefit from the root fix because they all usegetOwnerRepo().Changes
github-repository-identity.tsgetOwnerRepoupstream-first + newgetOriginOwnerRepogh-utils.tsgetOriginOwnerRepoclient.tsgetOriginOwnerRepoclient-create-pr.test.tscreateGitHubPullRequestclient.test.tsgetOriginOwnerRepomock, update 4getRepoUpstreamtestsgh-utils.test.tsVerification
Test results: 2291 passed, only 1 pre-existing unrelated failure (
pty-subprocessWSL test).Locally verified on a fork repo (
fsdwen/openclawwith upstreamopenclaw/openclaw):🤖 Generated with Claude Code