can1357/oh-my-pi · error · Error

missing value for ${flag}

Error message

missing value for ${flag}

What it means

The metaharness runner's parseArgs defines a take() helper for flags that require a value (e.g. --model, --provider). If a flag needing a value is the last argv entry (or no next argv element exists) and no inline value was given via =, take throws this Error naming the flag.

Source

Thrown at packages/metaharness/src/runner.ts:207

export function parseArgs(argv: string[]): Config {
	const cfg = defaultConfig();
	for (let i = 0; i < argv.length; i++) {
		let arg = argv[i];
		if (arg === "--") {
			cfg.passthrough.push(...argv.slice(i + 1));
			break;
		}
		let inlineValue: string | null = null;
		const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
		if (eq !== -1) {
			inlineValue = arg.slice(eq + 1);
			arg = arg.slice(0, eq);
		}
		const take = (flag: string): string => {
			if (inlineValue !== null) return inlineValue;
			const v = argv[i + 1];
			if (v === undefined) throw new Error(`missing value for ${flag}`);
			i++;
			return v;
		};
		switch (arg) {
			case "-m":
			case "--model":
				cfg.models.push(take(arg));
				break;
			case "--agent":
				cfg.agent = take(arg);
				break;
			case "--install": {
				const v = take(arg);
				if (v !== "source" && v !== "local" && v !== "published") {
					throw new Error("--install must be source|local|published");
				}
				cfg.install = v;
				break;

View on GitHub (pinned to 9690622007)

Solutions

  1. Append the value after the flag: --model anthropic/claude-sonnet-4-6 or --model=anthropic/claude-sonnet-4-6.
  2. Fix the calling script so variable expansions never drop the value (quote variables: "${MODEL}" and guard empties).
  3. Check the exact flag named in the error message and supply its missing value.
  4. Optionally pre-validate argv length in wrapper scripts before exec.

Example fix

# before
omp-runner --model   # missing value
# after
omp-runner --model anthropic/claude-sonnet-4-6
Defensive patterns

Strategy: validation

Validate before calling

function assertArgsComplete(argv: string[], valueFlags: string[]): void {
	for (let i = 0; i < argv.length; i++) {
		if (valueFlags.includes(argv[i]) && (i + 1 >= argv.length || argv[i + 1].startsWith("--"))) {
			throw new Error(`${argv[i]} requires a value`);
		}
	}
}

Try / catch

try {
	run(parseArgs(process.argv.slice(2)));
} catch (err) {
	if (err instanceof Error && err.message.startsWith("missing value for")) {
		console.error(`${err.message}\nusage: runner --model <provider/model> ...`);
		process.exit(2);
	}
	throw err;
}

Prevention

When it happens

Trigger: Invoking the runner with a trailing valueless flag: `runner -m`, `runner --model` with nothing after it, or `runner -p` at end of argv.

Common situations: Shell scripts building args conditionally so the value gets dropped (empty variable expansion); copy-pasted commands missing the value; wrappers that forward args but truncate the last one.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/b18ca56b09f3145c. Report an issue: GitHub.