{"record":{"id":"b89624d091477dad","repo":"abhigyanpatwari/GitNexus","slug":"source-branch-name-must-not-start-with","errorCode":null,"errorMessage":"${source}: branch name must not start with \"-\".","messagePattern":"(.+?): branch name must not start with \"-\"\\.","errorType":"validation","errorClass":"GitNexusRcError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/analyze-config.ts","lineNumber":177,"sourceCode":"  const trimmed = value.trim();\n  if (!trimmed) {\n    throw new GitNexusRcError(`${source}: branch name must not be empty.`);\n  }\n  if (trimmed.length > BRANCH_MAX_LENGTH) {\n    throw new GitNexusRcError(`${source}: branch name is too long (max ${BRANCH_MAX_LENGTH}).`);\n  }\n  assertNoHiddenChars(trimmed, source);\n  if (/\\s/.test(trimmed)) {\n    throw new GitNexusRcError(`${source}: branch name must not contain whitespace.`);\n  }\n  // git ref-name rules (subset): reject characters git itself forbids in refs.\n  if (/[~^:?*[\\\\]/.test(trimmed)) {\n    throw new GitNexusRcError(\n      `${source}: branch name contains characters not allowed in a git ref (~ ^ : ? * [ \\\\).`,\n    );\n  }\n  if (trimmed.startsWith('-')) {\n    throw new GitNexusRcError(`${source}: branch name must not start with \"-\".`);\n  }\n  if (trimmed.includes('..')) {\n    throw new GitNexusRcError(`${source}: branch name must not contain \"..\".`);\n  }\n  // Git permits a backtick in a ref, but the branch is embedded inside a\n  // Markdown inline-code span in the generated AGENTS.md/CLAUDE.md regression\n  // example, where a backtick would close the span early and let the rest of\n  // the template render as instruction text. Reject it at this single\n  // chokepoint so all three tiers (CLI flag, .gitnexusrc, auto-detect via\n  // sanitizeDetectedBranch) are covered (#1996 tri-review P1).\n  if (trimmed.includes('`')) {\n    throw new GitNexusRcError(\n      `${source}: branch name must not contain a backtick (it would break the generated Markdown).`,\n    );\n  }\n  return trimmed;\n}\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/cli/analyze-config.ts#L159-L195","documentation":"Thrown by validateBranchName() when the branch name starts with '-'. A leading dash makes the value look like a CLI flag, which would break argument parsing wherever the branch is later interpolated into a command or argument list.","triggerScenarios":"Passing --default-branch '-feature' or a name beginning with a dash from a config typo.","commonSituations":"A branch name autogenerated as '-' + ticket-id where the ticket id was empty; a copy-paste that included a leading dash from a markdown list item.","solutions":["Prefix the name with a letter or digit (e.g. 'feature/...' or 'T123-...').","If the leading dash was accidental, remove it.","Use git's conventional 'feature/', 'bugfix/', or 'release/' prefixes."],"exampleFix":"# before\ngitnexus analyze --default-branch \"-my-branch\"\n\n# after\ngitnexus analyze --default-branch \"my-branch\"","handlingStrategy":"validation","validationCode":"function assertNoLeadingDash(name: string): void {\n  if (name.startsWith('-')) {\n    throw new Error('branch name must not start with \"-\"');\n  }\n}","typeGuard":"function hasNoLeadingDash(name: string): boolean {\n  return typeof name === 'string' && !name.startsWith('-');\n}","tryCatchPattern":null,"preventionTips":["Prefix autogenerated branch names with a letter (e.g. 'ticket-123').","Use conventional prefixes like feature/, bugfix/, release/.","Inspect any name produced by string concatenation starting with a variable."],"tags":["validation","git","branch","config"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}