{"record":{"id":"ace6a4e54dc7bcc5","repo":"stablyai/orca","slug":"branch-name-must-not-start-with","errorCode":null,"errorMessage":"Branch name must not start with \"-\"","messagePattern":"Branch name must not start with \"-\"","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/ipc/worktree-remote.ts","lineNumber":555,"sourceCode":"    )\n  } catch {\n    // Best-effort cleanup; keep the sparse setup error as the actionable failure.\n  }\n}\n\nasync function resolveCreateBranchName(\n  repoPath: string,\n  branchNameOverride: string | undefined,\n  sanitizedName: string,\n  settings: BranchPrefixSettings,\n  username: string | null,\n  gitOptions: { wslDistro?: string } = {}\n): Promise<string> {\n  if (!branchNameOverride) {\n    return computeValidatedBranchName(sanitizedName, settings, username)\n  }\n  if (branchNameOverride.startsWith('-')) {\n    throw new Error('Branch name must not start with \"-\"')\n  }\n  await gitExecFileAsync(['check-ref-format', '--branch', branchNameOverride], {\n    cwd: repoPath,\n    ...gitOptions\n  })\n  return branchNameOverride\n}\n\nasync function resolveCreateBranchNameSsh(\n  provider: SshGitProvider,\n  repoPath: string,\n  branchNameOverride: string | undefined,\n  sanitizedName: string,\n  settings: BranchPrefixSettings,\n  username: string | null\n): Promise<string> {\n  if (!branchNameOverride) {\n    return computeValidatedBranchName(sanitizedName, settings, username)","sourceCodeStart":537,"sourceCodeEnd":573,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/main/ipc/worktree-remote.ts#L537-L573","documentation":"Thrown by resolveCreateBranchName for a LOCAL repo when the user-supplied branch name override begins with '-'. A leading hyphen would be parsed by git as an option flag rather than a ref, producing confusing behavior. The check runs before git check-ref-format --branch to give an unambiguous message. This is the local-repo (gitExecFileAsync) variant; the SSH variant is error 1322.","triggerScenarios":"A worktree create with args.branchNameOverride set to a string starting with '-' (e.g. '-feature', '--foo'), called against a local repo path. Reached at worktree-remote.ts:555 inside resolveCreateBranchName after the !branchNameOverride early return.","commonSituations":"CLI/UI prefilled a branch name from a ticket id that begins with '-'; a template or paste inserted a leading dash; automated tooling generating branch names from arbitrary input without sanitization.","solutions":["Strip or reject a leading '-' in branchNameOverride before calling the create API.","Validate the override with git check-ref-format --branch (or the same startsWith('-') guard) in the UI before submit.","If the dash is meaningful, rename the branch so the leading character is alphanumeric."],"exampleFix":"// before\nif (branchNameOverride.startsWith('-')) {\n  throw new Error('Branch name must not start with \"-\"')\n}\n\n// after — reject early at the caller with the user-facing fix\nif (branchNameOverride.startsWith('-')) {\n  throw new Error('Branch name must not start with \"-\". Remove the leading dash or prefix it (e.g. \"ticket-123\").')\n}","handlingStrategy":"validation","validationCode":"function isValidBranchOverride(name: string | undefined): boolean {\n  return !name || (!name.startsWith('-') && name.trim().length > 0)\n}\n// before create:\nif (!isValidBranchOverride(args.branchNameOverride)) {\n  return { ok: false, fieldError: 'branchName', message: 'Branch name must not start with \"-\".' }\n}","typeGuard":"function isSafeBranchName(name: string): boolean {\n  return name.length > 0 && !name.startsWith('-') && !name.startsWith('.') && !/[^\\x21-\\x7e]/.test(name) && !name.includes('..')\n}","tryCatchPattern":"catch (err) {\n  if (err instanceof Error && err.message.startsWith('Branch name must not start')) {\n    showFieldError('branchName', 'Remove the leading dash from the branch name.')\n  } else { throw err }\n}","preventionTips":["Sanitize generated branch names: strip leading dashes/dots before submit.","Run the same startsWith('-') guard in the renderer so the main process is never reached.","Factor the guard shared by resolveCreateBranchName and resolveCreateBranchNameSsh into one helper to avoid drift."],"tags":["worktree-create","branch-name","validation","git"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}