{"record":{"id":"68bb07d82460cc2e","repo":"abhigyanpatwari/GitNexus","slug":"flag-must-be-a-positive-integer","errorCode":null,"errorMessage":"${flag} must be a positive integer","messagePattern":"(.+?) must be a positive integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/wiki.ts","lineNumber":57,"sourceCode":"  gist?: boolean;\n  provider?: LLMProvider;\n  verbose?: boolean;\n  review?: boolean;\n  timeout?: string;\n  retries?: string;\n  lang?: string;\n  allowInsecureConnection?: string;\n}\n\nfunction parsePositiveIntegerOption(\n  value: string | undefined,\n  flag: string,\n  multiplier = 1,\n): number | undefined {\n  if (value === undefined) return undefined;\n  const trimmed = value.trim();\n  if (!/^[1-9]\\d*$/.test(trimmed)) {\n    throw new Error(`${flag} must be a positive integer`);\n  }\n  const parsed = parseInt(trimmed, 10);\n  if (parsed > Math.floor(Number.MAX_SAFE_INTEGER / multiplier)) {\n    throw new Error(`${flag} is too large`);\n  }\n  return parsed;\n}\n\nfunction isLocalProvider(\n  provider: LLMProvider | undefined,\n): provider is 'cursor' | 'claude' | 'codex' | 'opencode' {\n  return (\n    provider === 'cursor' ||\n    provider === 'claude' ||\n    provider === 'codex' ||\n    provider === 'opencode'\n  );\n}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/cli/wiki.ts#L39-L75","documentation":"The `gitnexus wiki` command parses positive-integer options (`--concurrency`, `--timeout`, `--retries`, and similar) via `parsePositiveIntegerOption`, which requires the regex /^[1-9]\\d*$/. Zero, negative numbers, floats, and non-numeric strings are rejected. The `flag` placeholder names the offending CLI flag.","triggerScenarios":"`gitnexus wiki --concurrency 0`, `--retries -1`, `--timeout 1.5`, or `--concurrency abc`.","commonSituations":"Passing 0 expecting 'unlimited' (it is invalid, not unlimited); decimal values; a stray unit suffix like 4x; copy-pasting a value in the wrong unit.","solutions":["Pass an integer greater than or equal to 1.","Omit the flag to use the built-in default.","If you need 'unlimited'/disabled semantics, check the flag's docs — 0 is not accepted here."],"exampleFix":"# before\ngitnexus wiki --concurrency 0\n# after\ngitnexus wiki --concurrency 4","handlingStrategy":"validation","validationCode":"function parsePositiveInt(value, flag) {\n  if (value === undefined) return undefined;\n  if (!/^[1-9]\\d*$/.test(value.trim())) throw new Error(flag + ' must be a positive integer');\n  return parseInt(value.trim(), 10);\n}","typeGuard":"const isPositiveIntegerString = (v) =>\n  typeof v === 'string' && /^[1-9]\\d*$/.test(v.trim());","tryCatchPattern":null,"preventionTips":["Pass integers >= 1; 0 is not 'unlimited' for these flags.","Omit the flag to accept the default if unsure."],"tags":["wiki","cli","validation","numeric"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}