abhigyanpatwari/GitNexus · error

${flag} must be a positive integer

Error message

${flag} must be a positive integer

What it means

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.

Source

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

  gist?: boolean;
  provider?: LLMProvider;
  verbose?: boolean;
  review?: boolean;
  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' {
  return (
    provider === 'cursor' ||
    provider === 'claude' ||
    provider === 'codex' ||
    provider === 'opencode'
  );
}

View on GitHub (pinned to d540b00184)

Solutions

  1. Pass an integer greater than or equal to 1.
  2. Omit the flag to use the built-in default.
  3. If you need 'unlimited'/disabled semantics, check the flag's docs — 0 is not accepted here.

Example fix

# before
gitnexus wiki --concurrency 0
# after
gitnexus wiki --concurrency 4
Defensive patterns

Strategy: validation

Validate before calling

function parsePositiveInt(value, flag) {
  if (value === undefined) return undefined;
  if (!/^[1-9]\d*$/.test(value.trim())) throw new Error(flag + ' must be a positive integer');
  return parseInt(value.trim(), 10);
}

Type guard

const isPositiveIntegerString = (v) =>
  typeof v === 'string' && /^[1-9]\d*$/.test(v.trim());

Prevention

When it happens

Trigger: `gitnexus wiki --concurrency 0`, `--retries -1`, `--timeout 1.5`, or `--concurrency abc`.

Common situations: 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.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/68bb07d82460cc2e. Report an issue: GitHub.