stablyai/orca · error · Error

Branch "${branchName}" already has PR #${lastExistingReviewN

Error message

Branch "${branchName}" already has PR #${lastExistingReviewNumber}. Pick a different ${branchConflictSubject}.

What it means

Local worktree create exhausted all suffixed candidate paths and the last collision was due to an existing PR/MR on the branch (lastExistingReviewNumber is set). Every suffix produced a name whose branch already has an open review, so the loop could not find a free name. The message cites the PR number so the user knows the conflict is review-based, not a bare branch or path collision.

Source

Thrown at src/main/ipc/worktree-remote.ts:2198

      }
    }

    worktreePath = ensurePathWithinWorkspace(
      computeWorktreePath(effectiveSanitizedName, repo.path, worktreePathSettings),
      workspaceRoot
    )
    if (existsSync(worktreePath)) {
      continue
    }

    resolved = true
    break
  }

  if (!resolved) {
    // Why: every suffix collided; reject with a specific reason so the user sees why create failed instead of a generic error or hung spinner.
    if (lastExistingReviewNumber !== null) {
      throw new Error(
        `Branch "${branchName}" already has PR #${lastExistingReviewNumber}. Pick a different ${branchConflictSubject}.`
      )
    }
    if (lastBranchConflictKind) {
      throw new Error(
        `Branch "${branchName}" already exists ${lastBranchConflictKind === 'local' ? 'locally' : 'on a remote'}. Pick a different ${branchConflictSubject}.`
      )
    }
    throw new Error(
      `Could not find an available worktree name for "${sanitizedName}". Pick a different worktree name.`
    )
  }

  validateWorkspaceLineageParentBeforeCreate(
    store,
    args.parentWorkspace,
    worktreeWorkspaceKey(`${repo.id}::${worktreePath}`)
  )

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Pick a different base worktree/branch name that has no associated PR.
  2. Close or merge the stale PRs blocking those branch names.
  3. Change the naming template so generated names avoid the colliding series.
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check: does the candidate branch already have an open PR?
const pr = await getOpenReviewNumber(repo, candidateBranch)
if (pr !== null) {
  return { ok: false, fieldError: 'branchName', message: `Branch "${candidateBranch}" already has PR #${pr}.` }
}

Try / catch

catch (err) {
  if (err instanceof Error && /already has PR #/.test(err.message)) {
    suggestNamesWithoutOpenReviews(repo, sanitizedName)
  } else { throw err }
}

Prevention

When it happens

Trigger: Local create name-collision loop where each candidate branch name maps to a branch with an existing PR/MR; resolved stays false; lastExistingReviewNumber is the last seen PR number. Reached at worktree-remote.ts:2198.

Common situations: Naming template collides with a series of branches that each already have PRs; a reused worktree base name where '-2', '-3' etc. all have reviews; CI/automation creating sequentially-numbered branches that accumulate PRs.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/95743b3beb162adf. Report an issue: GitHub.