abhigyanpatwari/GitNexus · error · Error

is too large

Error message

${flag} is too large

What it means

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.

Solutions

  1. Use a realistic magnitude: --timeout 600 (seconds become 600000 ms internally)
  2. Double the check if generating flags from variables: cap TIMEOUT to <= 9007199254740 before passing
  3. Treat this as a units smell — you are probably passing milliseconds/nanoseconds where the flag takes plain units

Example fix

# before
gitnexus wiki --timeout 1700000000000   # epoch-ms mistake
# after
gitnexus wiki --timeout 600
Defensive patterns

Strategy: validation

Validate before calling

const MAX_TIMEOUT = Math.floor(Number.MAX_SAFE_INTEGER / 1000); // --timeout multiplier is 1000
if (timeout !== undefined && timeout > MAX_TIMEOUT) {
  throw new Error(`--timeout must be <= ${MAX_TIMEOUT}`);
}

Type guard

const isSafeTimeoutArg = (v: number): boolean =>
  v > 0 && v <= Math.floor(Number.MAX_SAFE_INTEGER / 1000);

Try / catch

try {
  runWiki(options);
} catch (err) {
  if (err instanceof Error && err.message.endsWith('is too large')) {
    // almost certainly a units mistake — pass seconds/human-scale values, not epoch-ms
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: Scripts passing epoch timestamps or microsecond values where seconds were expected; copy-paste of large constants; a stray digit appended to a sane value.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-08-20). Data as JSON: /api/errors/00a842e2bcb88781. Report an issue: GitHub.

Appendix: source

Thrown at gitnexus/src/cli/wiki.ts:63

  timeout?: string;
  retries?: string;
  lang?: string;
  allowInsecureConnection?: string;
}

function parsePositiveIntegerOption(
  value: string | undefined,
  flag: string,
  multiplier = 1,
): number | undefined {
  if (value === undefined) return undefined;
  const trimmed = value.trim();
  if (!/^[1-9]\d*$/.test(trimmed)) {
    throw new Error(`${flag} must be a positive integer`);
  }
  const parsed = parseInt(trimmed, 10);
  if (parsed > Math.floor(Number.MAX_SAFE_INTEGER / multiplier)) {
    throw new Error(`${flag} is too large`);
  }
  return parsed;
}

function isLocalProvider(
  provider: LLMProvider | undefined,
): provider is 'cursor' | 'claude' | 'codex' | 'opencode' | 'grok' {
  return (
    provider === 'cursor' ||
    provider === 'claude' ||
    provider === 'codex' ||
    provider === 'opencode' ||
    provider === 'grok'
  );
}

function localModelConfigKey(provider: 'cursor' | 'claude' | 'codex' | 'opencode' | 'grok') {
  if (provider === 'cursor') return 'cursorModel';

View on GitHub (pinned to ac9a4e9abd)