stablyai/orca · error

Invalid worktree name

Error message

Invalid worktree name

What it means

Thrown by sanitizeWorktreeName when, after stripping unsafe characters and collapsing dot/hyphen runs, the result is empty, '.', or '..'. Git ref-format rejects refs named '.' or '..' and empty branch/dir names are unusable, so the sanitizer treats them as invalid input. The emoji-only special case returns 'workspace' instead, so this error specifically means the input reduced to nothing usable and contained no recognized emoji.

Source

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

  // git or the filesystem actually rejects.
  const sanitized = replaceKnownEmojiWithShortcodes(input)
    .trim()
    .replace(/[^\p{L}\p{N}._-]+/gu, '-')
    .replace(/-+/g, '-')
    // Why: git check-ref-format rejects any ref containing `..`, so a prompt
    // like "../../foo" that survives slugification as `..-..-foo` would
    // produce a branch name git refuses to create. Collapse runs of dots
    // to a single dot before the leading/trailing trim so internal `..`
    // sequences can't reach git.
    .replace(/\.{2,}/g, '.')
    .replace(/^[.-]+|[.-]+$/g, '')

  if (!sanitized && containsEmoji(input)) {
    return 'workspace'
  }

  if (!sanitized || sanitized === '.' || sanitized === '..') {
    throw new Error('Invalid worktree name')
  }

  return sanitized
}

function containsEmoji(input: string): boolean {
  return /[\p{Emoji_Presentation}\p{Extended_Pictographic}\p{Regional_Indicator}\u20e3]/u.test(
    input
  )
}

export function sanitizeWorktreeDisplayName(input: string): string | undefined {
  const withoutControls = Array.from(input, (char) => {
    const code = char.charCodeAt(0)
    return code <= 0x1f || (code >= 0x7f && code <= 0x9f) ? ' ' : char
  }).join('')
  const sanitized = withoutControls
    // Why: titles come from external systems. Strip bidi override controls so a

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Provide a name containing at least one Unicode letter or digit (CJK and accented letters are kept).
  2. Catch the error in the form layer and prompt the user to enter a valid name.
  3. If generating names programmatically, validate with a regex like /[\p{L}\p{N}]/u before calling sanitize, and fall back to a default.

Example fix

// before
sanitizeWorktreeName('...!!')
// after
sanitizeWorktreeName('feature-x')
Defensive patterns

Strategy: validation

Validate before calling

function hasUsableNameChar(input: string): boolean {
  return /[\p{L}\p{N}]/u.test(input) || /[\p{Emoji_Presentation}]/u.test(input)
}
if (!hasUsableNameChar(input)) {
  throw new Error('Name must contain at least one letter, digit, or emoji')
}

Type guard

function isSanitizableWorktreeName(input: string): boolean {
  if (!input || !input.trim()) return false
  return /[\p{L}\p{N}\p{Emoji_Presentation}]/u.test(input)
}

Try / catch

try {
  const name = sanitizeWorktreeName(input)
} catch (e) {
  if (/Invalid worktree name/.test((e as Error).message)) {
    showFieldError('name', 'Enter a name with at least one letter or digit.')
    return
  } else throw e
}

Prevention

When it happens

Trigger: sanitizeWorktreeName is called with an input consisting solely of characters stripped by the regex — e.g. only punctuation, spaces, control chars, or symbols with no Unicode letter/number — and no emoji. Examples: '!!!', '...', ' ', '---', or a string of arbitrary symbols.

Common situations: User types only punctuation/spaces in the worktree name field. A paste from elsewhere introduced only special characters. Programmatic caller passed an unfiltered token.

Related errors


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