{"record":{"id":"1de2acaec2db7169","repo":"n8n-io/n8n","slug":"invalid-integer-for-flag","errorCode":null,"errorMessage":"Invalid integer for ${flag}","messagePattern":"Invalid integer for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts","lineNumber":268,"sourceCode":"\t\treturn JSON.parse(content);\n\t} catch (error) {\n\t\tconst msg = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(`Failed to parse ${label} at ${path}: ${msg}`);\n\t}\n}\n\nfunction nextArg(argv: string[], i: number, flag: string): string {\n\tconst value = argv[i + 1];\n\tif (value === undefined || value.startsWith('--')) {\n\t\tthrow new Error(`Missing value for ${flag}`);\n\t}\n\treturn value;\n}\n\nfunction parseIntArg(argv: string[], i: number, flag: string): number {\n\tconst raw = nextArg(argv, i, flag);\n\tconst parsed = parseInt(raw, 10);\n\tif (Number.isNaN(parsed)) throw new Error(`Invalid integer for ${flag}`);\n\treturn parsed;\n}\n\n// ---------------------------------------------------------------------------\n// Build outcome + test-case prompt source\n//\n// The `claude -p` invocation, MCP config staging, prompt flattening, and\n// workflow-id extraction live in ./mcp-builder (shared with the fused\n// --build-via-mcp eval path). This file owns only the manifest/stats concerns.\n// ---------------------------------------------------------------------------\n\ninterface BuildOutcome {\n\tslug: string;\n\titeration: number;\n\tworkflowId: string | null;\n\tcost: number;\n\tturns: number;\n\tdurationMs: number;","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts#L250-L286","documentation":"The parseIntArg helper (line 265) calls nextArg to get the raw value, then parseInt(raw, 10). If the result is NaN, the value was not a valid base-10 integer and the error identifies which flag received the bad value. This catches non-numeric input before it silently becomes NaN in downstream iteration/concurrency/maxAttempts arithmetic.","triggerScenarios":"Running `pnpm eval:build-mcp-manifest --iterations abc`, `--concurrency x`, or any integer flag with a non-numeric token. Note: parseInt('1.5') returns 1 (not NaN), so floats with integer prefixes are accepted; only fully non-numeric values trigger this.","commonSituations":"Typo in a numeric argument (e.g. spelling out 'three' instead of 3). Copy-paste error. A variable expansion that produced an empty string or non-numeric value.","solutions":["Provide a valid whole number for the flag (e.g. --iterations 3)","Verify no accidental spaces or quotes around the value","Check that the value is numeric, not a word or empty string"],"exampleFix":"# before\npnpm eval:build-mcp-manifest --iterations three\n\n# after\npnpm eval:build-mcp-manifest --iterations 3","handlingStrategy":"validation","validationCode":"// Validate integer values in wrapper scripts before passing to the CLI:\nfunction parseIntOrThrow(raw: string, flag: string): number {\n  const n = Number.parseInt(raw, 10);\n  if (Number.isNaN(n)) throw new Error(`Invalid integer for ${flag}: ${raw}`);\n  return n;\n}","typeGuard":"function isIntegerString(v: string): boolean {\n  return /^-?\\d+$/.test(v.trim());\n}","tryCatchPattern":null,"preventionTips":["Pass only whole numbers (3, not 'three' or 3.5) to integer flags","Validate numeric args in wrapper scripts before forwarding to the CLI"],"tags":["cli","validation","argument-parsing","build-mcp-manifest"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}