{"record":{"id":"3dce5bc35ce6c5a3","repo":"stablyai/orca","slug":"invalid-parent-workspace-parentworkspace","errorCode":null,"errorMessage":"Invalid parent workspace: ${parentWorkspace}","messagePattern":"Invalid parent workspace: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-remote.ts","lineNumber":202,"sourceCode":"  fallbackPlatform: 'windows' | 'posix'\n): 'windows' | 'posix' {\n  return getSetupRunnerCommandPlatformForPath(setup?.runnerScriptPath ?? '', fallbackPlatform)\n}\n\nfunction validateWorkspaceLineageParentBeforeCreate(\n  store: Store,\n  parentWorkspace: CreateWorktreeArgs['parentWorkspace'],\n  childWorkspaceKey: ReturnType<typeof worktreeWorkspaceKey>\n): void {\n  if (!parentWorkspace) {\n    return\n  }\n  if (parentWorkspace === childWorkspaceKey) {\n    throw new Error('A worktree cannot be attached to itself.')\n  }\n  const parentScope = parseWorkspaceKey(parentWorkspace)\n  if (!parentScope) {\n    throw new Error(`Invalid parent workspace: ${parentWorkspace}`)\n  }\n  if (parentScope.type === 'folder' && !store.getFolderWorkspace(parentScope.folderWorkspaceId)) {\n    throw new Error(`Parent folder workspace not found: ${parentWorkspace}`)\n  }\n  if (parentScope.type === 'worktree' && !store.getWorktreeMeta(parentScope.worktreeId)) {\n    throw new Error(`Parent worktree workspace not found: ${parentWorkspace}`)\n  }\n}\n\nfunction recordWorkspaceLineageForCreatedWorktree(\n  store: Store,\n  args: CreateWorktreeArgs,\n  worktree: Worktree,\n  createdAt: number\n): CreateWorktreeResult['workspaceLineage'] {\n  if (!args.parentWorkspace || !worktree.instanceId) {\n    return null\n  }","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-remote.ts#L184-L220","documentation":"Thrown by validateWorkspaceLineageParentBeforeCreate when parseWorkspaceKey(parentWorkspace) returns null, meaning the parent key string does not match the expected workspace-key format (a typed prefix identifying it as a folder or worktree workspace). Without a parseable scope, the lineage validator cannot determine what kind of parent the user is referencing, so it rejects. This fires after the self-attachment check passes.","triggerScenarios":"createWorktree is called with a parentWorkspace value that is not a well-formed workspace key — e.g. a bare path, a repoId, a freeform string, or a truncated/malformed key. parseWorkspaceKey returns null/falsy.","commonSituations":"Caller constructs the parent key by hand and gets the format wrong. A persisted key was corrupted. Inter-version format change makes an old key unparseable by the current parser. Test fixture uses a synthetic invalid key.","solutions":["Build the parent key using the same worktreeWorkspaceKey helper the rest of the codebase uses, so the format matches.","Regenerate or migrate the parent key if it came from an older format.","Omit parentWorkspace for a top-level worktree if no valid parent is available."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"import { parseWorkspaceKey } from '<workspace-key-module>'\nif (args.parentWorkspace && !parseWorkspaceKey(args.parentWorkspace)) {\n  throw new Error('Parent workspace key is malformed')\n}","typeGuard":"function isValidWorkspaceKey(key: string): boolean {\n  return parseWorkspaceKey(key) !== null\n}","tryCatchPattern":"try {\n  await createWorktree(args)\n} catch (e) {\n  if (/Invalid parent workspace/.test((e as Error).message)) {\n    refreshWorkspaceList()\n    showNotification('The selected parent is invalid; please reselect.')\n    return\n  } else throw e\n}","preventionTips":["Build parent keys with the canonical worktreeWorkspaceKey helper, never by hand.","Re-parse and validate persisted keys after a format migration.","Omit parentWorkspace for top-level creation when in doubt."],"tags":["worktree","validation","lineage","workspace","parsing"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}