{"record":{"id":"2bb124a897ffbb4d","repo":"stablyai/orca","slug":"refusing-to-delete-unregistered-worktree-path-w","errorCode":null,"errorMessage":"Refusing to delete unregistered worktree path: ${worktreePath}","messagePattern":"Refusing to delete unregistered worktree path: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktrees.ts","lineNumber":2629,"sourceCode":"                  args.worktreeId,\n                  removedPushTarget,\n                  store,\n                  localWorktreeGitOptions\n                )\n                invalidateAuthorizedRootsCache()\n              }\n              runtime.clearOptimisticReconcileToken(args.worktreeId)\n              removeWorktreeMetadataAndTransientState(store, args.worktreeId, removalHostId)\n              preservedBranchCleanupByScope.delete(\n                preservedBranchCleanupScopeKey({\n                  worktreeId: args.worktreeId,\n                  hostId: removalHostId\n                })\n              )\n              notifyWorktreesChanged(mainWindow, repoId)\n              return {}\n            }\n            throw new Error(`Refusing to delete unregistered worktree path: ${worktreePath}`)\n          }\n          const canonicalWorktreePath = registeredWorktree.path\n          const deleteBranch = removedMeta?.preserveBranchOnDelete !== true\n\n          // Why: a Git lock must block before archive hooks or linked-path cleanup mutate the workspace; dirty-file force is separate.\n          try {\n            assertWorktreeUnlockedForRemoval(registeredWorktree)\n          } catch (error) {\n            throw new Error(\n              formatWorktreeRemovalError(error, canonicalWorktreePath, args.force ?? false)\n            )\n          }\n\n          // Why: a prior forced Windows recovery can delete the dir but leave a stale Git registration; verify before clearing metadata.\n          if (\n            !repo.connectionId &&\n            args.force === true &&\n            process.platform === 'win32' &&","sourceCodeStart":2611,"sourceCodeEnd":2647,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktrees.ts#L2611-L2647","documentation":"Final fallthrough throw in the unregistered-worktree branch of worktrees:remove: the path is not a Git-registered worktree, is not provably an Orca orphan (cleanup checks failed), and is not already removed. Orca refuses to delete an unregistered path it cannot prove is a worktree, rather than risk deleting an arbitrary directory.","triggerScenarios":"A worktrees:remove where the target path is unregistered by Git, fails the safe-orphan and leftover-directory checks, and isn't detected as already removed — i.e. an unregistered path Orca cannot safely classify.","commonSituations":"The worktreeId points at a path that was moved/renamed, is a non-worktree directory, or whose Git registration and Orca metadata are both inconsistent; or the path sits outside the repo and fails isDangerousWorktreeRemovalPath.","solutions":["Verify the path is actually a worktree of this repo (`git worktree list`); if not, no Orca removal applies.","If the registration is merely stale, run `git worktree prune` on the host and retry.","For genuinely orphaned Orca directories that fail the safety check, remove them manually rather than forcing Orca to delete an unproven path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Confirm the path is a registered worktree before attempting removal.\nconst worktrees = await invoke('worktrees:list', { repoId })\nconst exists = worktrees.some((w) => w.id === worktreeId)\nif (!exists) {\n  // Possibly stale; run prune or drop the row instead of forcing delete.\n  return\n}","typeGuard":null,"tryCatchPattern":"try {\n  await invoke('worktrees:remove', { worktreeId })\n} catch (e) {\n  if (e.message.startsWith('Refusing to delete unregistered worktree path')) {\n    // Inspect `git worktree list`; prune or remove manually — do not force blindly.\n  } else throw e\n}","preventionTips":["Run `git worktree prune` to resolve stale registrations before removing.","Never force-delete a path Orca cannot classify as a worktree.","Remove genuinely orphaned directories manually on the host."],"tags":["worktree-remove","safety","orphan-cleanup","unregistered"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}