{"record":{"id":"00a842e2bcb88781","repo":"abhigyanpatwari/GitNexus","slug":"flag-is-too-large","errorCode":null,"errorMessage":"${flag} is too large","messagePattern":"(.+?) is too large","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/wiki.ts","lineNumber":63,"sourceCode":"  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  );\n}\n\nfunction localModelConfigKey(provider: 'cursor' | 'claude' | 'codex' | 'opencode' | 'grok') {\n  if (provider === 'cursor') return 'cursorModel';","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/wiki.ts#L45-L81","documentation":"After passing the positive-integer regex, wiki.ts bounds-checks the parsed value against Number.MAX_SAFE_INTEGER divided by a per-flag multiplier (--timeout multiplies by 1000 to become milliseconds). Values that would overflow safe integer arithmetic when multiplied throw 'is too large' with the flag name.","triggerScenarios":"gitnexus wiki --timeout 90071992547410 (times 1000 exceeds 2^53-1), or --retries above ~9e15; the check is Math.floor(Number.MAX_SAFE_INTEGER / multiplier) at wiki.ts:61.","commonSituations":"Scripts passing epoch timestamps or microsecond values where seconds were expected; copy-paste of large constants; a stray digit appended to a sane value.","solutions":["Use a realistic magnitude: --timeout 600 (seconds become 600000 ms internally)","Double the check if generating flags from variables: cap TIMEOUT to <= 9007199254740 before passing","Treat this as a units smell — you are probably passing milliseconds/nanoseconds where the flag takes plain units"],"exampleFix":"# before\ngitnexus wiki --timeout 1700000000000   # epoch-ms mistake\n# after\ngitnexus wiki --timeout 600","handlingStrategy":"validation","validationCode":"const MAX_TIMEOUT = Math.floor(Number.MAX_SAFE_INTEGER / 1000); // --timeout multiplier is 1000\nif (timeout !== undefined && timeout > MAX_TIMEOUT) {\n  throw new Error(`--timeout must be <= ${MAX_TIMEOUT}`);\n}","typeGuard":"const isSafeTimeoutArg = (v: number): boolean =>\n  v > 0 && v <= Math.floor(Number.MAX_SAFE_INTEGER / 1000);","tryCatchPattern":"try {\n  runWiki(options);\n} catch (err) {\n  if (err instanceof Error && err.message.endsWith('is too large')) {\n    // almost certainly a units mistake — pass seconds/human-scale values, not epoch-ms\n  }\n}","preventionTips":["Keep --timeout in human-scale seconds (e.g. 600), never epoch timestamps or millisecond values","Bound generated flag values to <= ~9e12 for --timeout and <= Number.MAX_SAFE_INTEGER for --retries"],"tags":["cli","wiki","numeric-overflow","arguments"],"backgroundTag":"numeric-overflow","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"}