n8n-io/n8n · error · Error

Missing value for ${flag}

Error message

Missing value for ${flag}

What it means

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.

Source

Thrown at packages/@n8n/instance-ai/evaluations/cli/build-mcp-manifest.ts:260

	mkdirSync(result.logDir, { recursive: true });

	return { helpRequested: false, args: result };
}

function readJson(path: string, label: string): unknown {
	const content = readFileSync(path, 'utf-8');
	try {
		return JSON.parse(content);
	} catch (error) {
		const msg = error instanceof Error ? error.message : String(error);
		throw new Error(`Failed to parse ${label} at ${path}: ${msg}`);
	}
}

function nextArg(argv: string[], i: number, flag: string): string {
	const value = argv[i + 1];
	if (value === undefined || value.startsWith('--')) {
		throw new Error(`Missing value for ${flag}`);
	}
	return value;
}

function parseIntArg(argv: string[], i: number, flag: string): number {
	const raw = nextArg(argv, i, flag);
	const parsed = parseInt(raw, 10);
	if (Number.isNaN(parsed)) throw new Error(`Invalid integer for ${flag}`);
	return parsed;
}

// ---------------------------------------------------------------------------
// Build outcome + test-case prompt source
//
// The `claude -p` invocation, MCP config staging, prompt flattening, and
// workflow-id extraction live in ./mcp-builder (shared with the fused
// --build-via-mcp eval path). This file owns only the manifest/stats concerns.
// ---------------------------------------------------------------------------

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Provide the value immediately after the flag: --model claude-sonnet-4-6
  2. Check that the intended value does not start with --
  3. Re-examine the full command for missing or misplaced tokens

Example fix

# before
pnpm eval:build-mcp-manifest --model

# after
pnpm eval:build-mcp-manifest --model claude-sonnet-4-6
Defensive patterns

Strategy: validation

Validate before calling

// Validate that every value-taking flag has a non-flag value in argv:
function validateFlagValues(argv: string[], valueFlags: string[]): void {
  for (let i = 0; i < argv.length; i++) {
    if (valueFlags.includes(argv[i])) {
      const next = argv[i + 1];
      if (next === undefined || next.startsWith('--')) {
        throw new Error(`Missing value for ${argv[i]}`);
      }
    }
  }
}

Prevention

When it happens

Trigger: Running `pnpm eval:build-mcp-manifest --model` with nothing after it, or `--model --iterations 3` where the value position is occupied by another flag.

Common situations: 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.

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/d716968dc96be340. Report an issue: GitHub.