stablyai/orca · error

Invalid parent workspace: ${parentWorkspace}

Error message

Invalid parent workspace: ${parentWorkspace}

What it means

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.

Source

Thrown at src/main/ipc/worktree-remote.ts:202

  fallbackPlatform: 'windows' | 'posix'
): 'windows' | 'posix' {
  return getSetupRunnerCommandPlatformForPath(setup?.runnerScriptPath ?? '', fallbackPlatform)
}

function validateWorkspaceLineageParentBeforeCreate(
  store: Store,
  parentWorkspace: CreateWorktreeArgs['parentWorkspace'],
  childWorkspaceKey: ReturnType<typeof worktreeWorkspaceKey>
): void {
  if (!parentWorkspace) {
    return
  }
  if (parentWorkspace === childWorkspaceKey) {
    throw new Error('A worktree cannot be attached to itself.')
  }
  const parentScope = parseWorkspaceKey(parentWorkspace)
  if (!parentScope) {
    throw new Error(`Invalid parent workspace: ${parentWorkspace}`)
  }
  if (parentScope.type === 'folder' && !store.getFolderWorkspace(parentScope.folderWorkspaceId)) {
    throw new Error(`Parent folder workspace not found: ${parentWorkspace}`)
  }
  if (parentScope.type === 'worktree' && !store.getWorktreeMeta(parentScope.worktreeId)) {
    throw new Error(`Parent worktree workspace not found: ${parentWorkspace}`)
  }
}

function recordWorkspaceLineageForCreatedWorktree(
  store: Store,
  args: CreateWorktreeArgs,
  worktree: Worktree,
  createdAt: number
): CreateWorktreeResult['workspaceLineage'] {
  if (!args.parentWorkspace || !worktree.instanceId) {
    return null
  }

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Build the parent key using the same worktreeWorkspaceKey helper the rest of the codebase uses, so the format matches.
  2. Regenerate or migrate the parent key if it came from an older format.
  3. Omit parentWorkspace for a top-level worktree if no valid parent is available.
Defensive patterns

Strategy: type-guard

Validate before calling

import { parseWorkspaceKey } from '<workspace-key-module>'
if (args.parentWorkspace && !parseWorkspaceKey(args.parentWorkspace)) {
  throw new Error('Parent workspace key is malformed')
}

Type guard

function isValidWorkspaceKey(key: string): boolean {
  return parseWorkspaceKey(key) !== null
}

Try / catch

try {
  await createWorktree(args)
} catch (e) {
  if (/Invalid parent workspace/.test((e as Error).message)) {
    refreshWorkspaceList()
    showNotification('The selected parent is invalid; please reselect.')
    return
  } else throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/3dce5bc35ce6c5a3. Report an issue: GitHub.