{"record":{"id":"fbdf839cadbd7801","repo":"abhigyanpatwari/GitNexus","slug":"source-branch-name-is-too-long-max-branch-m","errorCode":null,"errorMessage":"${source}: branch name is too long (max ${BRANCH_MAX_LENGTH}).","messagePattern":"(.+?): branch name is too long \\(max (.+?)\\)\\.","errorType":"validation","errorClass":"GitNexusRcError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/analyze-config.ts","lineNumber":164,"sourceCode":"      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('..')) {\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","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/cli/analyze-config.ts#L146-L182","documentation":"Thrown by validateBranchName() when the trimmed branch name exceeds BRANCH_MAX_LENGTH (255 characters). Real git refs are short; a value over 255 bytes is almost certainly a paste error or an injection attempt, and git itself enforces similar limits.","triggerScenarios":"Passing a branch name longer than 255 characters, e.g. a long URL, a base64 blob, or a multi-line string pasted by accident.","commonSituations":"Pasting the wrong clipboard contents into --default-branch; a config value that accidentally captured a multi-line block; a generated name that concatenated several identifiers.","solutions":["Shorten the branch name to a real git ref (typically under 60 characters).","If the long value came from a script, check the source variable for a concatenation bug.","Omit the override and let auto-detect resolve the branch."],"exampleFix":"// before\n{ \"defaultBranch\": \"feature/very-long-description-continued-with-...-255+-chars\" }\n\n// after\n{ \"defaultBranch\": \"feature/short-name\" }","handlingStrategy":"validation","validationCode":"function checkBranchLength(name: string, max = 255): void {\n  if (name.trim().length > max) {\n    throw new Error(`branch name too long (${name.length} > ${max})`);\n  }\n}","typeGuard":"function isBranchLengthOk(name: string, max = 255): boolean {\n  return typeof name === 'string' && name.trim().length <= max;\n}","tryCatchPattern":null,"preventionTips":["Keep branch names short and descriptive (under 60 chars in practice).","If a name is autogenerated, cap its length at the source.","Suspect a paste error whenever a branch name exceeds ~60 characters."],"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"}