{"record":{"id":"424e29d413f9a1e7","repo":"abhigyanpatwari/GitNexus","slug":"source-branch-name-must-not-be-empty","errorCode":null,"errorMessage":"${source}: branch name must not be empty.","messagePattern":"(.+?): branch name must not be empty\\.","errorType":"validation","errorClass":"GitNexusRcError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/analyze-config.ts","lineNumber":161,"sourceCode":"  for (const ch of value) {\n    const cp = ch.codePointAt(0);\n    if (cp !== undefined && isHiddenOrControl(cp)) {\n      throw new GitNexusRcError(\n        `${source}: value contains control or hidden/bidirectional characters, which are not allowed.`,\n      );\n    }\n  }\n};\n\n/**\n * Validate a user-supplied branch name (from CLI or `.gitnexusrc`). Returns the\n * trimmed name or throws {@link GitNexusRcError}. Conservative but accepts the\n * shapes real branches use (`feature/foo-bar`, `release/1.2`, `develop`).\n */\nexport function validateBranchName(value: string, source: string): string {\n  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('..')) {","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/cli/analyze-config.ts#L143-L179","documentation":"Thrown by validateBranchName() when the trimmed branch name is the empty string. Branch names flow into the generated AGENTS.md/CLAUDE.md regression example as a git checkout command, so an empty value would produce a broken command with no signal to the user.","triggerScenarios":"Passing --default-branch '' (empty), --default-branch '   ' (whitespace only), or a .gitnexusrc with \"defaultBranch\": \"\".","commonSituations":"A CI job that sets DEFAULT_BRANCH from an env var that is sometimes empty; clearing a branch override by passing an empty string rather than omitting the flag; a config template with a placeholder that was never filled.","solutions":["Omit the flag/keys entirely to let the resolver fall through to auto-detect or the 'main' fallback.","Pass a real branch name that matches your repo's default.","If deriving from git, fall back to the detected origin/HEAD rather than an empty string."],"exampleFix":"# before\ngitnexus analyze --default-branch \"\"\n\n# after (omit the flag)\ngitnexus analyze","handlingStrategy":"validation","validationCode":"function resolveBranch(cli?: string, config?: string, detected?: string | null): string {\n  const candidates = [cli, config, detected].filter((v) => typeof v === 'string' && v.trim() !== '');\n  return candidates.length ? candidates[0]! : 'main';\n}","typeGuard":"function isNonEmptyBranch(value: unknown): value is string {\n  return typeof value === 'string' && value.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Omit --default-branch rather than passing an empty string when you want auto-detect.","Treat an empty DEFAULT_BRANCH env var as 'unset', not as a value.","Let the resolver fall through to origin/HEAD detection or the 'main' fallback."],"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"}