{"record":{"id":"3eb393cde944c62d","repo":"n8n-io/n8n","slug":"missing-value-for-flag-3eb393","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/computer-use/cli.ts","lineNumber":122,"sourceCode":"\t\t\t\tbreak;\n\t\t\tcase '--keep-data':\n\t\t\t\traw.keepData = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tif (arg.startsWith('--')) {\n\t\t\t\t\tthrow new Error(`Unknown flag: ${arg.split('=', 1)[0]}`);\n\t\t\t\t}\n\t\t\t\tthrow new Error('Unexpected positional argument');\n\t\t}\n\t}\n\n\treturn argsSchema.parse(raw);\n}\n\nfunction next(argv: string[], idx: number, flag: string): string {\n\tconst value = argv[idx + 1];\n\tif (value === undefined || value.startsWith('--')) {\n\t\tthrow new Error(`Missing value for ${flag}`);\n\t}\n\treturn value;\n}\n\n// ---------------------------------------------------------------------------\n// Scenario discovery\n// ---------------------------------------------------------------------------\n\nasync function discoverScenarios(dataDir: string, filter?: string): Promise<Scenario[]> {\n\tconst entries = await readdir(dataDir);\n\tconst files = entries.filter((f) => f.endsWith('.json'));\n\tconst scenarios: Scenario[] = [];\n\n\tfor (const file of files) {\n\t\tconst raw = await readFile(join(dataDir, file), 'utf-8');\n\t\tconst parsed = jsonParse<Scenario>(raw, { errorMessage: `Invalid scenario JSON in ${file}` });\n\t\tif (filter && !parsed.id.includes(filter) && !file.includes(filter)) continue;\n\t\tscenarios.push(withDefaultGraders(parsed));","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/computer-use/cli.ts#L104-L140","documentation":"Thrown by the `next()` helper in computer-use/cli.ts when a value-bearing flag is followed by either end-of-argv or another `--` token. The helper deliberately treats a following `--flag` as 'you forgot the value' rather than consuming it as a value, so `--base-url --filter slack` is read as a missing value for `--base-url`, not `--base-url=--filter`. Protects against silently setting a flag's value to the name of another flag.","triggerScenarios":"`--base-url` as the last token on the command line. `--filter --verbose` (intended `--filter foo --verbose`). `--email --password secret` (forgot the email value). Any value-bearing flag whose value legitimately starts with `--` (rare but possible — e.g. a password that starts with dashes) cannot be expressed positionally and must be supplied another way.","commonSituations":"Developers reorder flags and forget the value. CI YAML strips an empty environment variable that was meant to be interpolated as the value, leaving the flag dangling. A password or token starting with `--` cannot be passed positionally at all here.","solutions":["Supply the missing value immediately after the flag: `--base-url http://localhost:5678`.","If a value legitimately starts with `--` (e.g. a token), this parser cannot express it inline — pass it via the corresponding environment variable or a config file instead, or pre-process argv to use a `=` form the parser does not currently support (requires a code change).","Audit CI scripts for `${VAR}` interpolations that may resolve to empty and leave a flag dangling."],"exampleFix":"// before\n$ node cli.ts --base-url --filter slack\n// after\n$ node cli.ts --base-url http://localhost:5678 --filter slack","handlingStrategy":"validation","validationCode":"// Pair each value-bearing flag with its value before invoking.\nconst VALUE_FLAGS = new Set(['--base-url','--email','--password','--filter','--timeout-ms','--output-dir','--daemon-sandbox-dir']);\nfunction checkValues(argv: string[]): string[] {\n  const problems: string[] = [];\n  for (let i = 0; i < argv.length; i++) {\n    if (VALUE_FLAGS.has(argv[i])) {\n      const next = argv[i + 1];\n      if (next === undefined || next.startsWith('--')) problems.push(argv[i]);\n    }\n  }\n  return problems;\n}\nconst missing = checkValues(process.argv.slice(2));\nif (missing.length) throw new Error(`Missing values for: ${missing.join(', ')}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["In CI, assert that every value-bearing flag has a non-empty interpolation target before invoking.","If you need to pass a value starting with `--`, extend the parser to support `--flag=--value` rather than fighting the helper.","Document the no-leading-dashes constraint on values prominently."],"tags":["cli","argument-parsing","configuration","developer-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}