n8n-io/n8n · error · Error
${name} must be a positive integer, got "${raw}".
Error message
${name} must be a positive integer, got "${raw}". What it means
parsePositiveInt validates CLI numeric flags (e.g. --judges, --iterations) that must be positive integers. It rejects undefined/empty (returns undefined), but throws on NaN, non-finite, zero, negative, or fractional values. The error names the flag and shows the raw input.
Source
Thrown at packages/@n8n/instance-ai/evaluations/cli/pairwise.ts:115
maxExamples: parsePositiveInt(get('--max-examples'), '--max-examples'),
exampleIds,
examplesJsonl: get('--examples-jsonl'),
timeoutMs:
parsePositiveNumber(get('--timeout-ms'), '--timeout-ms') ?? Number(DEFAULTS.TIMEOUT_MS),
outputDir: get('--output-dir') ?? defaultOutputDir,
judgeModel: get('--judge-model') ?? 'claude-sonnet-4-5-20250929',
experimentName: get('--experiment-name') ?? 'pairwise-evals-instance-ai',
verbose: has('--verbose'),
baseUrl: get('--base-url') ?? process.env.N8N_EVAL_BASE_URL ?? 'http://localhost:5678',
keepWorkflows: has('--keep-workflows'),
};
}
function parsePositiveInt(raw: string | undefined, name: string): number | undefined {
if (raw === undefined || raw === '') return undefined;
const n = Number(raw);
if (!Number.isFinite(n) || n <= 0 || !Number.isInteger(n)) {
throw new Error(`${name} must be a positive integer, got "${raw}".`);
}
return n;
}
function parsePositiveNumber(raw: string | undefined, name: string): number | undefined {
if (raw === undefined || raw === '') return undefined;
const n = Number(raw);
if (!Number.isFinite(n) || n <= 0) {
throw new Error(`${name} must be a positive number, got "${raw}".`);
}
return n;
}
// ---------------------------------------------------------------------------
// Dataset loading
// ---------------------------------------------------------------------------
interface DatasetExample {View on GitHub (pinned to 5ac6606e81)
Solutions
- Re-run the CLI with a positive integer value for the named flag.
- If the value comes from a script, coerce with Math.max(1, Math.floor(Number(x))) and validate before passing.
- Check the flag's help text to confirm it expects an integer count.
Example fix
// before: pnpm pairwise --iterations 0 // after: pnpm pairwise --iterations 3
Defensive patterns
Strategy: validation
Validate before calling
function asPositiveInt(raw: string | undefined, name: string): number | undefined {
if (raw === undefined || raw === '') return undefined;
const n = Number(raw);
if (!Number.isFinite(n) || n <= 0 || !Number.isInteger(n))
throw new Error(`${name} must be a positive integer`);
return n;
} Type guard
const isPositiveInt = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v) && v > 0 && Number.isInteger(v);
Prevention
- Validate numeric args at the edge before invoking the CLI.
- Document each flag's domain (count vs rate).
- Use a CLI parser with built-in integer coercion.
When it happens
Trigger: Passing `--iterations 0`, `--judges -1`, `--iterations 2.5`, or `--judges abc` to the pairwise CLI.
Common situations: Off-by-one in scripts generating the flag; copy/paste of a decimal where an integer is required; env-driven shells passing empty strings interpreted oddly.
Related errors
- ${name} must be a positive number, got "${raw}".
- LangSmith mode requires `--dataset` and does not support `--
- --max-attempts must be >= 1
- --source langtracer requires --suite <slug>
- Missing value for ${flag}
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/4cd19b604755a838.
Report an issue: GitHub.