{"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":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/wiki.ts","lineNumber":59,"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' | 'grok' {\n  return (\n    provider === 'cursor' ||\n    provider === 'claude' ||\n    provider === 'codex' ||\n    provider === 'opencode' ||\n    provider === 'grok'\n  );","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/wiki.ts#L41-L77","documentation":"Wiki generation parses its numeric options with a strict positive-integer regex ^[1-9]\\d*$ (no sign, no decimals, no exponent, no zero). The flags involved are --timeout and --retries; any value that is not a plain positive integer string throws with the flag name in the message.","triggerScenarios":"gitnexus wiki --timeout 0 (zero is rejected), --retries -1, --timeout 1.5, --timeout 10s, --retries abc, or an empty string option value; leading/trailing whitespace is trimmed first so only the digits themselves matter.","commonSituations":"Using 0 to mean 'no limit' or 'disabled' (not supported here); passing values with units ('30s'); shell scripts computing empty strings for unset variables; JSON configs feeding the option with a float.","solutions":["Pass a plain whole number >= 1: gitnexus wiki --timeout 30 --retries 3","For 'no timeout/retries intent', omit the flag (undefined is skipped) rather than passing 0","In scripts, guard: [ -n \"$TIMEOUT\" ] && gitnexus wiki --timeout \"$TIMEOUT\" || gitnexus wiki"],"exampleFix":"# before\ngitnexus wiki --timeout 0\n# after\ngitnexus wiki   # omit --timeout, or use a positive value like --timeout 30","handlingStrategy":"validation","validationCode":"function positiveIntArg(v: string | undefined, flag: string): number | undefined {\n  if (v === undefined) return undefined;\n  if (!/^[1-9]\\d*$/.test(v.trim())) throw new Error(`${flag} must be a positive integer`);\n  return parseInt(v, 10);\n}\n// validate before spawning gitnexus wiki","typeGuard":"const isPositiveIntegerString = (v: string): boolean =>\n  /^[1-9]\\d*$/.test(v.trim());","tryCatchPattern":"try {\n  runWiki(options);\n} catch (err) {\n  if (err instanceof Error && err.message.endsWith('must be a positive integer')) {\n    // the flag name is at the start of the message — fix or drop that flag (0 is not valid)\n  }\n}","preventionTips":["--timeout and --retries take plain integers >= 1; 0 is invalid, so omit the flag to use defaults","No units ('30s'), floats, or negative numbers","In shell wrappers, only pass the flag when the variable is non-empty"],"tags":["cli","wiki","validation","arguments"],"backgroundTag":"invalid-cli-argument","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}