stablyai/orca · error

Invalid worktreeId: ${worktreeId}

Error message

Invalid worktreeId: ${worktreeId}

What it means

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).

Source

Thrown at src/main/ipc/worktree-logic.ts:231

 * Determine whether a display name should be persisted.
 * A display name is set only when the user's requested name differs from
 * both the branch name and the sanitized name (i.e. it was modified).
 */
export function shouldSetDisplayName(
  requestedName: string,
  branchName: string,
  sanitizedName: string
): boolean {
  return !(branchName === requestedName && sanitizedName === requestedName)
}

/**
 * Parse a composite worktreeId ("repoId::worktreePath") into its parts.
 */
export function parseWorktreeId(worktreeId: string): { repoId: string; worktreePath: string } {
  const parsed = splitWorktreeId(worktreeId)
  if (!parsed) {
    throw new Error(`Invalid worktreeId: ${worktreeId}`)
  }
  return parsed
}

/**
 * Check whether a git error indicates the worktree is no longer tracked by git.
 * This happens when a worktree's internal git tracking is removed (e.g. via
 * `git worktree prune`) but the directory still exists on disk.
 */
export function isOrphanedWorktreeError(error: unknown): boolean {
  if (!(error instanceof Error)) {
    return false
  }
  const msg = (error as { stderr?: string }).stderr || error.message
  return /is not a working tree/.test(msg)
}

export function isWindowsLongPathWorktreeRemovalError(

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Use splitWorktreeId (the null-returning variant) when the ID may legitimately be a repoId-only, and handle null gracefully.
  2. Ensure the value passed is a full composite worktreeId of the form 'repoId::worktreePath'.
  3. Validate with indexOf('::') !== -1 before calling parseWorktreeId, and surface a clearer upstream error if missing.

Example fix

// before
const { repoId, worktreePath } = parseWorktreeId(maybeRepoIdOnly)
// after
const parsed = splitWorktreeId(maybeRepoIdOnly)
if (!parsed) { throw new Error(`Expected worktreeId, got: ${maybeRepoIdOnly}`) }
const { repoId, worktreePath } = parsed
Defensive patterns

Strategy: type-guard

Validate before calling

import { splitWorktreeId } from '../../shared/worktree-id'
function isCompositeWorktreeId(id: string): boolean {
  return splitWorktreeId(id) !== null
}

Type guard

import { splitWorktreeId, type ParsedWorktreeId } from '../../shared/worktree-id'
function isCompositeWorktreeId(id: string): id is string & { __parsed: ParsedWorktreeId } {
  return splitWorktreeId(id) !== null
}

Try / catch

const parsed = splitWorktreeId(worktreeId)
if (!parsed) {
  throw new Error(`Expected a composite worktreeId (repoId::worktreePath), got: ${worktreeId}`)
}
const { repoId, worktreePath } = parsed

Prevention

When it happens

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

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

Related errors


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