Repository navigation
Conversation
📝 WalkthroughWalkthroughThe change adds shared validators for Git remote names and push-target URLs. Relay validation now permits only safe fork remote add and remove commands. Git mutation detection recognizes these commands. Worktree push-target setup removes newly created remotes after fetch failures while preserving existing remotes. SSH setup translates older relay authorization errors. Tests cover validation, remote lifecycle operations, rollback behavior, and SSH worktree creation. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
⚔️ Resolve merge conflicts 💡
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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2fa4d8f5-0d1b-4d0b-9654-529a7cf8b492
📥 Commits
Reviewing files that changed from the base of the PR and between e7b047f and 759c8ba22122c69de57773066bd255771fcb46a6.
📒 Files selected for processing (11)
src/main/ipc/worktree-push-target-cleanup.test.tssrc/main/ipc/worktree-push-target-setup.test.tssrc/main/ipc/worktree-push-target-setup.tssrc/main/ipc/worktree-remote.tssrc/main/ipc/worktrees-ssh-fork-push-target-remote.test.tssrc/relay/git-exec-validator.test.tssrc/relay/git-exec-validator.tssrc/relay/git-handler-fork-remote-exec.test.tssrc/shared/git-exec-mutation.test.tssrc/shared/git-exec-mutation.tssrc/shared/git-push-target-validation.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| if (remoteCreated) { | ||
| await execGit(['remote', 'remove', remoteName], repoPath).catch(() => {}) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Separate persistent remote ownership from invocation-local rollback state. Both setup paths use remoteCreated for two different meanings. A reused remote that another worktree owns can be removed when the new worktree fetch fails.
src/main/ipc/worktree-push-target-setup.ts#L111-L113: remove the remote only when this invocation added it.src/main/ipc/worktree-remote.ts#L1126-L1128: apply the same rollback condition for SSH setup.src/main/ipc/worktree-push-target-setup.test.ts#L217-L240: add a failed-fetch case where the reuse callback returnstrue, then assert no removal.src/main/ipc/worktrees-ssh-fork-push-target-remote.test.ts#L215-L268: add the equivalent SSH case for a known owned remote, then assert no removal.
📍 Affects 4 files
src/main/ipc/worktree-push-target-setup.ts#L111-L113(this comment)src/main/ipc/worktree-remote.ts#L1126-L1128src/main/ipc/worktree-push-target-setup.test.ts#L217-L240src/main/ipc/worktrees-ssh-fork-push-target-remote.test.ts#L215-L268
| import { | ||
| isSafeGitRemoteName, | ||
| isSafePushTargetRemoteUrl | ||
| } from '../shared/git-push-target-validation' |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Keep the relay bundle independent.
src/relay is deployed as a separate bundle. This import crosses into the app-side src/shared bundle and can break remote relay deployment. Define the validators locally in src/relay and keep their rules synchronized with src/shared/git-push-target-validation.ts.
Based on learnings: avoid importing app-side modules, including shared constants, from src/relay.
Source: Learnings
Fork-PR setup adds the contributor's remote, then fetches the head. If that fetch fails the create aborts, but the remote stayed behind with no owner: cleanup only runs on worktree removal, and no worktree was ever created. Each retry then left another orphaned pr-* remote. Roll the remote back on fetch failure, on both the local and SSH paths, and only when this call is what added it -- a reused remote (Orca-created or not) is left alone.
759c8ba to
37be655
Compare
stablyai#15850) Fork-PR setup adds the contributor's remote, then fetches the head. If that fetch fails the create aborts, but the remote stayed behind with no owner: cleanup only runs on worktree removal, and no worktree was ever created. Each retry then left another orphaned pr-* remote. Roll the remote back on fetch failure, on both the local and SSH paths, and only when this call is what added it -- a reused remote (Orca-created or not) is left alone. (cherry picked from commit a157f4c)
stablyai#15850) Fork-PR setup adds the contributor's remote, then fetches the head. If that fetch fails the create aborts, but the remote stayed behind with no owner: cleanup only runs on worktree removal, and no worktree was ever created. Each retry then left another orphaned pr-* remote. Roll the remote back on fetch failure, on both the local and SSH paths, and only when this call is what added it -- a reused remote (Orca-created or not) is left alone.
stablyai#15850) Fork-PR setup adds the contributor's remote, then fetches the head. If that fetch fails the create aborts, but the remote stayed behind with no owner: cleanup only runs on worktree removal, and no worktree was ever created. Each retry then left another orphaned pr-* remote. Roll the remote back on fetch failure, on both the local and SSH paths, and only when this call is what added it -- a reused remote (Orca-created or not) is left alone.
ELI5
Follow-up to #15827. When Orca sets up a workspace for a fork PR it does two things in a row: "remember where this contributor's copy lives" (
git remote add), then "go download their branch" (git fetch). If the download fails — flaky network, private fork, deleted branch — the whole workspace creation gives up, but the remote we just wrote stayed in the repo forever. Nothing ever cleaned it up, because the cleanup only runs when you delete a workspace and no workspace was ever created. Retry three times, get three junkpr-*remotes.Now, if the fetch fails, we take the remote back out.
Detail
prepareWorktreePushTargetWithExec(local) andprepareWorktreePushTargetSsh(SSH) bothremote addthen fetch, with no rollback. Flagged as a P2 residual during the readiness review of #15827; the SSH path only became reachable in that PR, so this is a good time to fix both.Rollback is gated on
remoteCreated— the flag already tracking whether this call added the remote — so a reused remote is never touched, whether Orca created it earlier or the user added it by hand. The rollback itself is best-effort (.catch(() => {})) so it can't mask the fetch error that actually aborted the create.Tests
worktree-push-target-setup.test.ts— the local path removes a remote it just added on fetch failure, and leaves a reused remote alone. The stateful fake git now modelsremote remove, so the assertion is on real resulting state, not just the argv.worktrees-ssh-fork-push-target-remote.test.ts— same for SSH throughworktrees:create, with the provider'sexecstill routed through the real relay validator, andaddWorktreeasserted never to run.Verified: full
src/relay+src/main/ipc+src/sharedsuites (9,775 tests),oxlint,tsc -p config/tsconfig.node.json.