can1357/oh-my-pi · error · Error
missing value for ${arg}
Error message
missing value for ${arg} What it means
The CLI arg parser's take() helper returns an option's value: either an inline `--flag=value` value or the next argv entry. When the flag is last in argv with no inline value, the next token is undefined and this error is thrown naming the flag.
Source
Thrown at packages/metaharness/src/tb/cli.ts:122
vmonUrl: "http://xeon.internal:17970",
vmonToken: "",
list: false,
help: false,
};
let modelsSpecified = false;
for (let i = 0; i < argv.length; i++) {
let arg = argv[i];
let inlineValue: string | null = null;
const equals = arg.startsWith("--") ? arg.indexOf("=") : -1;
if (equals !== -1) {
inlineValue = arg.slice(equals + 1);
arg = arg.slice(0, equals);
}
const take = (): string => {
if (inlineValue !== null) return inlineValue;
const value = argv[++i];
if (value === undefined) throw new Error(`missing value for ${arg}`);
return value;
};
switch (arg) {
case "-m":
case "--model":
if (!modelsSpecified) {
config.models = [];
modelsSpecified = true;
}
config.models.push(take());
break;
case "--dataset":
config.dataset = take();
break;
case "-i":
case "--include":
config.include.push(take());
break;View on GitHub (pinned to 9690622007)
Solutions
- Append the missing value after the flag (e.g. `tb --model anthropic/claude-sonnet-4`)
- Or use the inline form `--model=anthropic/claude-sonnet-4`
- In scripts, quote variables so empty values are not dropped: tb --model "$MODEL"
Example fix
// before $ tb --model // after $ tb --model anthropic/claude-sonnet-4
Defensive patterns
Strategy: validation
Validate before calling
function hasValue(argv: string[], flag: string): boolean {
const i = argv.indexOf(flag);
return i === -1 || (i + 1 < argv.length && !argv[i + 1].startsWith("-")) || flag.includes("=");
} Try / catch
try {
config = parseArgs(process.argv.slice(2));
} catch (err) {
if (String(err.message).startsWith("missing value for")) {
console.error(`${err.message}; usage: tb --model <provider/model>`);
process.exit(2);
}
throw err;
} Prevention
- Quote shell variables so empty values are preserved
- Use the --flag=value inline form to bind values explicitly
- Wrap CLI invocations in a usage-check script
When it happens
Trigger: Invoking e.g. `tb --model` (or -m, --gateway-url, --openrouter-variant, etc.) as the final argument with no following token and no `=` form.
Common situations: Truncated copy-paste of a command line; shell history trimming; scripts building argv where the value variable is empty and gets dropped by word splitting (e.g. unquoted empty shell variable).
Related errors
- missing value for ${flag}
- unknown option: ${arg}
- missing operand
- Expected --${name} to be a positive integer, got ${value}
- Cache flags require --cache
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/94e632e11583fcbf.
Report an issue: GitHub.