{"record":{"id":"0361f75471795484","repo":"stablyai/orca","slug":"could-not-find-an-available-worktree-name-for-s","errorCode":null,"errorMessage":"Could not find an available worktree name for \"${sanitizedName}\". Pick a different worktree name.","messagePattern":"Could not find an available worktree name for \"(.+?)\"\\. Pick a different worktree name\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-remote.ts","lineNumber":2207,"sourceCode":"    }\n\n    resolved = true\n    break\n  }\n\n  if (!resolved) {\n    // Why: every suffix collided; reject with a specific reason so the user sees why create failed instead of a generic error or hung spinner.\n    if (lastExistingReviewNumber !== null) {\n      throw new Error(\n        `Branch \"${branchName}\" already has PR #${lastExistingReviewNumber}. Pick a different ${branchConflictSubject}.`\n      )\n    }\n    if (lastBranchConflictKind) {\n      throw new Error(\n        `Branch \"${branchName}\" already exists ${lastBranchConflictKind === 'local' ? 'locally' : 'on a remote'}. Pick a different ${branchConflictSubject}.`\n      )\n    }\n    throw new Error(\n      `Could not find an available worktree name for \"${sanitizedName}\". Pick a different worktree name.`\n    )\n  }\n\n  validateWorkspaceLineageParentBeforeCreate(\n    store,\n    args.parentWorkspace,\n    worktreeWorkspaceKey(`${repo.id}::${worktreePath}`)\n  )\n\n  if (remoteTrackingRefresh) {\n    await timing.time('refresh_base_ref', async () => {\n      const result = await remoteTrackingRefresh.promise\n      if (!result.ok && !remoteTrackingRefresh.hadLocalBaseRef) {\n        // Why: only block create when the refresh failed AND there's no local base ref; an existing (possibly stale) ref keeps worktree add viable.\n        throw new Error(\n          `Could not refresh base ref \"${baseBranch}\" from \"${remoteTrackingRefresh.base.remote}\". Check your network and try again.`\n        )","sourceCodeStart":2189,"sourceCodeEnd":2225,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-remote.ts#L2189-L2225","documentation":"Local worktree create exhausted all suffixed candidate paths with neither a branch conflict nor a PR conflict recorded — resolved stayed false and both lastExistingReviewNumber and lastBranchConflictKind are null. This is a pure path-collision failure: every candidate worktreePath already exists on disk (existsSync true), unrelated to branches or reviews.","triggerScenarios":"Local create loop where existsSync(worktreePath) is true for every candidate and no branch/PR conflict was recorded. Reached at worktree-remote.ts:2207 (final fallback throw).","commonSituations":"Many worktrees with the same base name already on disk; orphaned directories from crashed/partial deletes; very long names truncating into collisions; suffix range too small for the number of existing worktrees.","solutions":["Pick a more unique worktree name.","Remove orphaned worktree directories left by failed deletes (git worktree prune, then rm the folders).","Widen the candidate suffix range or change the worktree path template."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { existsSync } from 'fs'\nfor (const candidate of buildNameCandidates(sanitizedName)) {\n  const p = resolveWorktreePath(repo, candidate)\n  if (!existsSync(p)) return { ok: true, worktreePath: p }\n}\nreturn { ok: false, error: `All candidate paths for \"${sanitizedName}\" already exist.` }","typeGuard":null,"tryCatchPattern":"catch (err) {\n  if (err instanceof Error && err.message.startsWith('Could not find an available worktree name')) {\n    promptForDifferentWorktreeName()\n  } else { throw err }\n}","preventionTips":["Choose distinctive worktree names.","Prune orphaned worktree dirs (git worktree prune) after failed deletes.","Expand the naming template suffix range."],"tags":["worktree-create","path-collision","local","naming"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}