abhigyanpatwari/GitNexus · error · Error
must be a positive integer
Error message
${flag} must be a positive integer What it means
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.
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
Example fix
# before gitnexus wiki --timeout 0 # after gitnexus wiki # omit --timeout, or use a positive value like --timeout 30
Defensive patterns
Strategy: validation
Validate before calling
function positiveIntArg(v: string | undefined, flag: string): number | undefined {
if (v === undefined) return undefined;
if (!/^[1-9]\d*$/.test(v.trim())) throw new Error(`${flag} must be a positive integer`);
return parseInt(v, 10);
}
// validate before spawning gitnexus wiki Type guard
const isPositiveIntegerString = (v: string): boolean => /^[1-9]\d*$/.test(v.trim());
Try / catch
try {
runWiki(options);
} catch (err) {
if (err instanceof Error && err.message.endsWith('must be a positive integer')) {
// the flag name is at the start of the message — fix or drop that flag (0 is not valid)
}
} Prevention
- --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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- is too large
- must be a positive integer
- must not exceed
- OpenCode CLI returned no text output
- CLI found but --version failed (exit ).status ?? '?'})…
AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-08-20).
Data as JSON: /api/errors/68bb07d82460cc2e.
Report an issue: GitHub.
Appendix: source
Thrown at gitnexus/src/cli/wiki.ts:59
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' | 'grok' {
return (
provider === 'cursor' ||
provider === 'claude' ||
provider === 'codex' ||
provider === 'opencode' ||
provider === 'grok'
);View on GitHub (pinned to ac9a4e9abd)