{"record":{"id":"7bb9f0abff1c368a","repo":"abhigyanpatwari/GitNexus","slug":"must-not-start-with","errorCode":null,"errorMessage":"must not start with \"-\"","messagePattern":"must not start with \"-\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/auto-sync/config.ts","lineNumber":339,"sourceCode":"    !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  )\n    throw new Error('must not contain hidden, trailing-dot, or .lock path components');\n}\n\nexport function parseDurationMs(value: unknown): number {","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/auto-sync/config.ts#L321-L357","documentation":"A branch name starting with '-' would be interpreted by git command lines as an option flag rather than a ref (argument injection), so validateAutoSyncBranchName rejects it as its own explicit check. The library throws at config parse time via parseAutoSyncConfig, before any git invocation.","triggerScenarios":"branches: [\"--force\"], [\"-main\"], or a config where a flag like '--all' was accidentally placed in the branches list; a generated value that lost its prefix, e.g. an env var '-b main' fragment.","commonSituations":"Someone tried to pass git flags through the branches list; shell history fragments pasted into config; scripts emitting '- ' list markers into the value itself.","solutions":["Remove the leading '-' and use the actual branch name (e.g. -main → main).","Never put git flags in the branches list — flags are not supported there.","If you intended a dash-separated name, ensure the dash is not first: my-branch is fine, -branch is not."],"exampleFix":"// before\nbranches:\n  - \"--all\"\n// after\nbranches:\n  - main","handlingStrategy":"validation","validationCode":"function noLeadingDash(b) {\n  return typeof b === 'string' && !b.startsWith('-');\n}\nconst bad = (cfg.branches ?? []).filter((b) => !noLeadingDash(b));\nif (bad.length) throw new Error(`branches must not start with '-': ${JSON.stringify(bad)}`);","typeGuard":null,"tryCatchPattern":"try {\n  validateAutoSyncBranchName(branch);\n} catch (e) {\n  if (String(e.message).includes('must not start with \"-\"')) {\n    log.error(`'${branch}' looks like a git flag; put the actual branch name in branches[].`);\n  }\n  throw e;\n}","preventionTips":["Never place git CLI flags (--force, --all) in the branches list.","Sanitize any user/script-provided branch value for a leading dash.","Treat branches[] entries as pure ref names, not command fragments."],"tags":["config","git","branch","security","argument-injection"],"backgroundTag":"invalid-argument-value","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"}