{"record":{"id":"32eb0a0870eed954","repo":"n8n-io/n8n","slug":"unexpected-positional-argument","errorCode":null,"errorMessage":"Unexpected positional argument","messagePattern":"Unexpected positional argument","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/cli/args.ts","lineNumber":512,"sourceCode":"\t\t\t\ti++;\n\t\t\t\tbreak;\n\n\t\t\tcase '--build-timeout-ms':\n\t\t\t\tresult.buildTimeoutMs = parseIntArg(argv, i, '--build-timeout-ms');\n\t\t\t\tresult.buildOnlyFlags.push(arg);\n\t\t\t\ti++;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\t// Fail loudly on unknown flags. Strip any =value payload before\n\t\t\t\t// echoing and drop positional values entirely — raw CLI input\n\t\t\t\t// may contain secrets (e.g. --password=... or an accidentally\n\t\t\t\t// pasted token) that would otherwise leak into terminal/CI logs.\n\t\t\t\tif (arg.startsWith('--')) {\n\t\t\t\t\tconst flagName = arg.split('=', 1)[0];\n\t\t\t\t\tthrow new Error(`Unknown flag: ${flagName}`);\n\t\t\t\t}\n\t\t\t\tthrow new Error('Unexpected positional argument');\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nfunction nextArg(argv: string[], currentIndex: number, flagName: string): string {\n\tconst value = argv[currentIndex + 1];\n\tif (value === undefined || value.startsWith('--')) {\n\t\tthrow new Error(`Missing value for ${flagName}`);\n\t}\n\treturn value;\n}\n","sourceCodeStart":494,"sourceCodeEnd":530,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/cli/args.ts#L494-L530","documentation":"Thrown by the default case of parseRawArgs() (args.ts:512) when an argument does not start with -- and is not consumed as a flag value. Unlike build-mcp-manifest.ts (which accepts positional slug arguments), this eval CLI parser does not accept any positional arguments — all configuration must come through flags. The error is thrown without echoing the positional value, because raw CLI input may contain secrets (e.g. an accidentally pasted token).","triggerScenarios":"Passing a bare positional argument to the eval CLI, e.g. `pnpm eval:instance-ai some-slug` or `pnpm eval:instance-ai ./path`. Any token that is not a --flag and is not the value of a preceding flag triggers it.","commonSituations":"A developer confuses this CLI with build-mcp-manifest (which accepts positional slugs), or passes a test-case filter as a positional instead of via --filter. Also triggered by a shell glob expanding into a bare token.","solutions":["Convert the positional into the appropriate flag form: test-case substrings go to --filter, file paths go to --prebuilt-workflows or --output-dir.","Remove the positional argument if it was unintended.","Review the parseRawArgs switch cases to find the correct flag for your intent."],"exampleFix":"// before\npnpm eval:instance-ai contact-form --base-url http://localhost:5678\n// after\npnpm eval:instance-ai --filter contact-form --base-url http://localhost:5678","handlingStrategy":"validation","validationCode":"function assertNoPositionals(args: string[]): void {\n  for (let i = 0; i < args.length; i++) {\n    const a = args[i];\n    if (!a.startsWith('--')) {\n      // It's a positional only if the previous flag didn't consume it as a value.\n      const prev = args[i - 1];\n      const valueFlags = new Set(['--timeout-ms','--base-url','--email','--password','--filter','--exclude','--prebuilt-workflows','--output-dir','--iterations','--dataset','--concurrency','--experiment-name','--pin-ai-roots','--tier','--baseline-prefix','--source','--suite','--mcp-server','--build-cwd','--build-max-attempts','--build-mcp-timeout-ms','--build-timeout-ms']);\n      if (!prev || !valueFlags.has(prev.split('=',1)[0])) {\n        throw new Error(`Unexpected positional argument: ${a}`);\n      }\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember the eval CLI takes no positionals — unlike build-mcp-manifest which accepts slugs.","Convert any slug-style input to --filter <substring>.","Validate command shape in a wrapper script before exec."],"tags":["cli","argument-validation","security","instance-ai"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}