{"record":{"id":"d716968dc96be340","repo":"n8n-io/n8n","slug":"missing-value-for-flag","errorCode":null,"errorMessage":"Missing value for ${flag}","messagePattern":"Missing value for (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts","lineNumber":260,"sourceCode":"\tmkdirSync(result.logDir, { recursive: true });\n\n\treturn { helpRequested: false, args: result };\n}\n\nfunction readJson(path: string, label: string): unknown {\n\tconst content = readFileSync(path, 'utf-8');\n\ttry {\n\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// ---------------------------------------------------------------------------","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts#L242-L278","documentation":"The nextArg helper (line 257) fetches the token immediately following a flag in argv. It throws when the next token is undefined (the flag is the last argument) or starts with '--' (the next token looks like another flag, not a value). This prevents flags from being silently consumed as values for other flags.","triggerScenarios":"Running `pnpm eval:build-mcp-manifest --model` with nothing after it, or `--model --iterations 3` where the value position is occupied by another flag.","commonSituations":"Developer forgets to provide a value after a value-taking flag. Two flags are accidentally adjacent. Shell quoting or variable expansion produces an empty or missing token.","solutions":["Provide the value immediately after the flag: --model claude-sonnet-4-6","Check that the intended value does not start with --","Re-examine the full command for missing or misplaced tokens"],"exampleFix":"# before\npnpm eval:build-mcp-manifest --model\n\n# after\npnpm eval:build-mcp-manifest --model claude-sonnet-4-6","handlingStrategy":"validation","validationCode":"// Validate that every value-taking flag has a non-flag value in argv:\nfunction validateFlagValues(argv: string[], valueFlags: string[]): void {\n  for (let i = 0; i < argv.length; i++) {\n    if (valueFlags.includes(argv[i])) {\n      const next = argv[i + 1];\n      if (next === undefined || next.startsWith('--')) {\n        throw new Error(`Missing value for ${argv[i]}`);\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always provide a value immediately after each value-taking flag","Double-check that values do not start with '--'","Review the full command line before pressing enter"],"tags":["cli","validation","argument-parsing","build-mcp-manifest"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}