{"record":{"id":"ff43c6aa8a08e163","repo":"stablyai/orca","slug":"invalid-worktree-name","errorCode":null,"errorMessage":"Invalid worktree name","messagePattern":"Invalid worktree name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-logic.ts","lineNumber":46,"sourceCode":"  // git or the filesystem actually rejects.\n  const sanitized = replaceKnownEmojiWithShortcodes(input)\n    .trim()\n    .replace(/[^\\p{L}\\p{N}._-]+/gu, '-')\n    .replace(/-+/g, '-')\n    // Why: git check-ref-format rejects any ref containing `..`, so a prompt\n    // like \"../../foo\" that survives slugification as `..-..-foo` would\n    // produce a branch name git refuses to create. Collapse runs of dots\n    // to a single dot before the leading/trailing trim so internal `..`\n    // sequences can't reach git.\n    .replace(/\\.{2,}/g, '.')\n    .replace(/^[.-]+|[.-]+$/g, '')\n\n  if (!sanitized && containsEmoji(input)) {\n    return 'workspace'\n  }\n\n  if (!sanitized || sanitized === '.' || sanitized === '..') {\n    throw new Error('Invalid worktree name')\n  }\n\n  return sanitized\n}\n\nfunction containsEmoji(input: string): boolean {\n  return /[\\p{Emoji_Presentation}\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20e3]/u.test(\n    input\n  )\n}\n\nexport function sanitizeWorktreeDisplayName(input: string): string | undefined {\n  const withoutControls = Array.from(input, (char) => {\n    const code = char.charCodeAt(0)\n    return code <= 0x1f || (code >= 0x7f && code <= 0x9f) ? ' ' : char\n  }).join('')\n  const sanitized = withoutControls\n    // Why: titles come from external systems. Strip bidi override controls so a","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-logic.ts#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"User types only punctuation/spaces in the worktree name field. A paste from elsewhere introduced only special characters. Programmatic caller passed an unfiltered token.","solutions":["Provide a name containing at least one Unicode letter or digit (CJK and accented letters are kept).","Catch the error in the form layer and prompt the user to enter a valid name.","If generating names programmatically, validate with a regex like /[\\p{L}\\p{N}]/u before calling sanitize, and fall back to a default."],"exampleFix":"// before\nsanitizeWorktreeName('...!!')\n// after\nsanitizeWorktreeName('feature-x')","handlingStrategy":"validation","validationCode":"function hasUsableNameChar(input: string): boolean {\n  return /[\\p{L}\\p{N}]/u.test(input) || /[\\p{Emoji_Presentation}]/u.test(input)\n}\nif (!hasUsableNameChar(input)) {\n  throw new Error('Name must contain at least one letter, digit, or emoji')\n}","typeGuard":"function isSanitizableWorktreeName(input: string): boolean {\n  if (!input || !input.trim()) return false\n  return /[\\p{L}\\p{N}\\p{Emoji_Presentation}]/u.test(input)\n}","tryCatchPattern":"try {\n  const name = sanitizeWorktreeName(input)\n} catch (e) {\n  if (/Invalid worktree name/.test((e as Error).message)) {\n    showFieldError('name', 'Enter a name with at least one letter or digit.')\n    return\n  } else throw e\n}","preventionTips":["Require at least one Unicode letter or digit in the name field before enabling submit.","Reject punctuation/symbol-only inputs upstream.","For programmatic callers, validate with a Unicode-aware regex before sanitizing."],"tags":["worktree","validation","git-ref","input-sanitization","naming"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}