{"record":{"id":"30dcf771ae77850f","repo":"abhigyanpatwari/GitNexus","slug":"must-not-be-empty","errorCode":null,"errorMessage":"must not be empty","messagePattern":"must not be empty","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/auto-sync/config.ts","lineNumber":335,"sourceCode":"  // strict superset, so anything accepted here is accepted there.\n  const lastSegment = pathParts[pathParts.length - 1];\n  const repoName = /\\.git$/i.test(lastSegment) ? lastSegment.slice(0, -4) : lastSegment;\n  if (\n    !repoName ||\n    repoName === '.' ||\n    repoName === '..' ||\n    repoName === 'unknown' ||\n    repoName.startsWith('-') ||\n    !REMOTE_REPO_NAME_PATTERN.test(repoName)\n  ) {\n    throw new Error(\n      'repository name must use only letters, digits, \".\", \"_\", or \"-\" and must not be \"unknown\"',\n    );\n  }\n}\n\nexport function validateAutoSyncBranchName(branch: string): void {\n  if (!branch.trim()) throw new Error('must not be empty');\n  if (/[\\s\\0-\\x1f\\x7f]/.test(branch))\n    throw new Error('must not contain whitespace or control characters');\n  if (/[~^:?*[\\\\]/.test(branch)) throw new Error('contains characters not allowed in a git ref');\n  if (branch.startsWith('-')) throw new Error('must not start with \"-\"');\n  if (branch.startsWith('/')) throw new Error('must not start with \"/\"');\n  if (branch.includes('..')) throw new Error('must not contain \"..\"');\n  if (branch.includes('`')) throw new Error('must not contain backticks');\n  if (branch.endsWith('/') || branch.endsWith('.')) throw new Error('must not end with \"/\" or \".\"');\n  if (branch.includes('//')) throw new Error('must not contain consecutive slashes');\n  if (branch.includes('@{')) throw new Error('must not contain \"@{\"');\n  if (\n    branch\n      .split('/')\n      .some(\n        (component) =>\n          component.startsWith('.') || component.endsWith('.') || component.endsWith('.lock'),\n      )\n  )","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/auto-sync/config.ts#L317-L353","documentation":"validateAutoSyncBranchName rejects an empty or whitespace-only branch name as the first check. Auto-sync needs a concrete branch to fetch/checkout; an empty value would produce a broken git command, so the library fails fast at config parse time via parseAutoSyncConfig.","triggerScenarios":"branches: [\"\"] or branches: [\"   \"] in the auto-sync config; a template/variable that failed to interpolate leaving an empty string; a YAML list entry that is only whitespace or a stray '- ' item.","commonSituations":"Generated config where the branch env var was unset; copy-pasted YAML with an empty bullet; refactoring that removed the branch name but left the list entry.","solutions":["Set the branch to a real branch name, e.g. branches: [\"main\"].","Delete the empty entry from the branches list instead of leaving a placeholder.","If the branch comes from a variable/env value, verify it is set before starting auto-sync.","Trim the value — whitespace-only strings count as empty."],"exampleFix":"// before\nbranches:\n  - \"\"\n// after\nbranches:\n  - main","handlingStrategy":"validation","validationCode":"function branchNonEmpty(b) {\n  return typeof b === 'string' && b.trim().length > 0;\n}\nconst branches = (cfg.branches ?? []).filter(branchNonEmpty);\nif (branches.length === 0) throw new Error('at least one non-empty branch is required');","typeGuard":"function isNonEmptyBranch(v) {\n  return typeof v === 'string' && v.trim() !== '';\n}","tryCatchPattern":"try {\n  const cfg = parseAutoSyncConfig(raw);\n} catch (e) {\n  if (String(e.message) === 'must not be empty') {\n    log.error('A branches[] entry is empty; provide a real branch name like \"main\".');\n  }\n  throw e;\n}","preventionTips":["Filter out empty/whitespace entries when building the branches list.","Check that interpolated variables/env values are set before writing config.","Review YAML for stray '- ' bullets with no value.","Validate config in CI before deployment."],"tags":["config","git","branch","validation"],"backgroundTag":"empty-required-field","analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-09-08T00:40:44.970Z","contentChangedAt":"2026-09-08T00:40:44.970Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}