{"record":{"id":"c1173e8cfffbdc9e","repo":"abhigyanpatwari/GitNexus","slug":"flag-must-be-a-positive-integer-c1173e","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/analyze-watch.ts","lineNumber":90,"sourceCode":"  readonly maxFileSize: string | undefined;\n  readonly workerTimeout: string | undefined;\n  readonly verbose: string | undefined;\n}\n\nfunction setEnvironment(name: string, value: string | undefined): void {\n  if (value === undefined) delete process.env[name];\n  else process.env[name] = value;\n}\n\nfunction positiveInteger(\n  value: string | undefined,\n  flag: string,\n  maximum?: number,\n): number | undefined {\n  if (value === undefined) return undefined;\n  const parsed = Number(value);\n  if (!Number.isInteger(parsed) || parsed < 1)\n    throw new Error(`${flag} must be a positive integer`);\n  if (maximum !== undefined && parsed > maximum) {\n    throw new Error(`${flag} must not exceed ${maximum}`);\n  }\n  return parsed;\n}\n\nexport async function resolveWatchOptions(\n  repoPath: string,\n  cli: WatchCliOptions,\n  baseline: WatchEnvironmentBaseline,\n  reportIgnoredConfig: (names: readonly string[]) => void = () => {},\n): Promise<CoreAnalyzeOptions> {\n  const config = (await loadAnalyzeConfigStrict(repoPath)) ?? {};\n  const merged = mergeAnalyzeOptions(cli, config);\n  const unsupported = [\n    ['--force', cli.force],\n    ['--no-parse-cache', cli.parseCache === false],\n    ['--repair-fts', cli.repairFts],","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/cli/analyze-watch.ts#L72-L108","documentation":"positiveInteger() validates that a CLI flag value for `gitnexus analyze --watch` is an integer >= 1 before it is used (e.g. worker pool size, timeout, max file size). It throws when Number(value) is NaN, a non-integral number, or less than 1. This guards the watch pipeline from nonsensical numeric configuration.","triggerScenarios":"Passing --worker-pool-size=0, --worker-timeout-seconds=2.5, --max-file-size=abc, or any flag routed through positiveInteger with a value that parses to NaN, a float, or an integer < 1.","commonSituations":"Typo in a numeric flag value, copy-pasting a float from documentation, shell variable expanding empty or to a unit-suffixed string like '10mb', or setting a value to 0 expecting 'unlimited'.","solutions":["Pass a whole number >= 1 for the flag (e.g. --worker-pool-size 4).","Remove unit suffixes and quotes: use --max-file-size 1048576, not 10mb.","Check the shell variable actually expands to a bare integer (echo it) before invoking the CLI.","If a maximum applies, stay at or below it (see the companion 'must not exceed' error)."],"exampleFix":"// before\ngitnexus analyze --watch --worker-pool-size 0\n// after\ngitnexus analyze --watch --worker-pool-size 4","handlingStrategy":"validation","validationCode":"function isValidPositiveInt(v) {\n  const n = Number(v);\n  return v !== undefined && Number.isInteger(n) && n >= 1;\n}\nif (!isValidPositiveInt(process.argv.workerPoolSize)) throw new Error('workerPoolSize must be a positive integer');","typeGuard":"const isPositiveInt = (v: unknown): v is number =>\n  typeof v === 'number' && Number.isInteger(v) && v >= 1;","tryCatchPattern":null,"preventionTips":["Never pass 0 or floats to numeric watch flags","Avoid unit suffixes ('10mb') — pass raw integers","Echo interpolated shell variables before invoking the CLI"],"tags":["cli","validation","numeric-argument"],"backgroundTag":"invalid-cli-argument","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"}