{"record":{"id":"bb21ba1e48642b68","repo":"stablyai/orca","slug":"repo-not-found-repoid","errorCode":null,"errorMessage":"Repo not found: ${repoId}","messagePattern":"Repo not found: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktrees.ts","lineNumber":2365,"sourceCode":"      return runtime.resolveManagedMrBase({\n        repoSelector: `id:${args.repoId}`,\n        mrIid: args.mrIid,\n        sourceBranch: args.sourceBranch,\n        targetBranch: args.targetBranch,\n        isCrossRepository: args.isCrossRepository\n      })\n    }\n  )\n\n  const worktreeRemovalsInFlight = new Map<string, WorktreeRemovalInFlight>()\n\n  ipcMain.handle(\n    'worktrees:remove',\n    async (_event, args: RemoveWorktreeArgs): Promise<RemoveWorktreeResult> => {\n      const { repoId, worktreePath } = parseWorktreeId(args.worktreeId)\n      const repo = getRepoForWorktreeRemoval(store, repoId, args.hostId)\n      if (!repo) {\n        throw new Error(`Repo not found: ${repoId}`)\n      }\n      // The resolved repo supplies host ownership when legacy callers omit args.hostId.\n      const removalHostId = getRepoExecutionHostId(repo)\n      const inFlightKey = getWorktreeRemovalInFlightKey(args.worktreeId, removalHostId)\n      const optionsKey = getWorktreeRemovalOptionsKey(args)\n      const inFlightRemoval = worktreeRemovalsInFlight.get(inFlightKey)\n      if (inFlightRemoval) {\n        if (inFlightRemoval.optionsKey === optionsKey) {\n          return inFlightRemoval.promise\n        }\n        throw new Error(`Worktree deletion already in progress: ${args.worktreeId}`)\n      }\n\n      // Why: concurrent stale-toast/double-click/sidebar races can hit the same worktree; share the op so only one path touches Git and disk.\n      const removal = (async (): Promise<RemoveWorktreeResult> => {\n        // Why: worktree.create is traced; delete freezes were invisible without a matching worktree.remove parent span.\n        return withWorktreeSpan({ stage: 'remove', path: worktreePath }, async () => {\n          if (isFolderRepo(repo)) {","sourceCodeStart":2347,"sourceCodeEnd":2383,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktrees.ts#L2347-L2383","documentation":"Thrown at the top of the worktrees:remove handler when getRepoForWorktreeRemoval returns undefined. That helper refuses to guess: it returns undefined if the repoId+hostId filter matches more than one owner, matches none, or the legacy getRepo fallback disagrees with the host scope. Deletion must resolve a single owning repo.","triggerScenarios":"A worktrees:remove call whose repoId (parsed from worktreeId) is unknown, or whose args.hostId matches multiple host-owned copies of the same repo id (ambiguous ownership), or whose hostId doesn't match any owner.","commonSituations":"Renderer sends a stale worktreeId after the repo was removed; a worktree id is shared across a local and an SSH-owned copy of the same repo id and the caller omitted/ mismatched hostId; or the repo was deleted between listing and removal.","solutions":["Pass the correct args.hostId matching the worktree's owning host so getRepoForWorktreeRemoval resolves exactly one repo.","Refresh repo/worktree state and remove a still-registered worktree.","If the repo genuinely has multiple host owners with the same id, disambiguate by host before calling remove."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Resolve exactly one owning repo before removing.\nconst repo = await invoke('repos:resolveForRemoval', { repoId, hostId })\nif (!repo) {\n  throw new Error(`No unique repo owner for ${repoId} on host ${hostId}`)\n}\nawait invoke('worktrees:remove', { worktreeId, hostId })","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the hostId matching the worktree's owner.","Refresh worktree state before removing.","For repos shared across hosts, disambiguate by host explicitly."],"tags":["validation","ipc","worktree-remove","repo-lookup","host-ownership"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}