{"record":{"id":"f0e256c2b4d0d062","repo":"stablyai/orca","slug":"invalid-worktreeid-worktreeid","errorCode":null,"errorMessage":"Invalid worktreeId: ${worktreeId}","messagePattern":"Invalid worktreeId: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-logic.ts","lineNumber":231,"sourceCode":" * Determine whether a display name should be persisted.\n * A display name is set only when the user's requested name differs from\n * both the branch name and the sanitized name (i.e. it was modified).\n */\nexport function shouldSetDisplayName(\n  requestedName: string,\n  branchName: string,\n  sanitizedName: string\n): boolean {\n  return !(branchName === requestedName && sanitizedName === requestedName)\n}\n\n/**\n * Parse a composite worktreeId (\"repoId::worktreePath\") into its parts.\n */\nexport function parseWorktreeId(worktreeId: string): { repoId: string; worktreePath: string } {\n  const parsed = splitWorktreeId(worktreeId)\n  if (!parsed) {\n    throw new Error(`Invalid worktreeId: ${worktreeId}`)\n  }\n  return parsed\n}\n\n/**\n * Check whether a git error indicates the worktree is no longer tracked by git.\n * This happens when a worktree's internal git tracking is removed (e.g. via\n * `git worktree prune`) but the directory still exists on disk.\n */\nexport function isOrphanedWorktreeError(error: unknown): boolean {\n  if (!(error instanceof Error)) {\n    return false\n  }\n  const msg = (error as { stderr?: string }).stderr || error.message\n  return /is not a working tree/.test(msg)\n}\n\nexport function isWindowsLongPathWorktreeRemovalError(","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-logic.ts#L213-L249","documentation":"Thrown by parseWorktreeId when splitWorktreeId returns null, i.e. the worktreeId string contains no WORKTREE_ID_SEPARATOR ('::'). A valid composite worktreeId is 'repoId::worktreePath'; without the separator the string cannot be split into its two parts, so parsing fails. parseWorktreeId is the strict variant (the non-throwing splitWorktreeId returns null instead).","triggerScenarios":"parseWorktreeId is called with a bare repoId ('repo-123'), an empty string, or any value missing the '::' separator. splitWorktreeId returns null and parseWorktreeId throws. Common when a caller assumes every worktreeId is composite but receives a repo-only or malformed identifier.","commonSituations":"A repoId is passed where a worktreeId was expected (type confusion). A persisted/serialized ID was truncated. A new code path constructs an ID without the separator. Test fixture uses a malformed ID.","solutions":["Use splitWorktreeId (the null-returning variant) when the ID may legitimately be a repoId-only, and handle null gracefully.","Ensure the value passed is a full composite worktreeId of the form 'repoId::worktreePath'.","Validate with indexOf('::') !== -1 before calling parseWorktreeId, and surface a clearer upstream error if missing."],"exampleFix":"// before\nconst { repoId, worktreePath } = parseWorktreeId(maybeRepoIdOnly)\n// after\nconst parsed = splitWorktreeId(maybeRepoIdOnly)\nif (!parsed) { throw new Error(`Expected worktreeId, got: ${maybeRepoIdOnly}`) }\nconst { repoId, worktreePath } = parsed","handlingStrategy":"type-guard","validationCode":"import { splitWorktreeId } from '../../shared/worktree-id'\nfunction isCompositeWorktreeId(id: string): boolean {\n  return splitWorktreeId(id) !== null\n}","typeGuard":"import { splitWorktreeId, type ParsedWorktreeId } from '../../shared/worktree-id'\nfunction isCompositeWorktreeId(id: string): id is string & { __parsed: ParsedWorktreeId } {\n  return splitWorktreeId(id) !== null\n}","tryCatchPattern":"const parsed = splitWorktreeId(worktreeId)\nif (!parsed) {\n  throw new Error(`Expected a composite worktreeId (repoId::worktreePath), got: ${worktreeId}`)\n}\nconst { repoId, worktreePath } = parsed","preventionTips":["Prefer splitWorktreeId (null-returning) when the input may legitimately be repoId-only.","Reserve parseWorktreeId for paths where a composite ID is contractually guaranteed.","Check indexOf(WORKTREE_ID_SEPARATOR) !== -1 before parsing untrusted input."],"tags":["worktree","validation","parsing","identifier","ipc"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}