garrytan/gstack · error · Error
Missing value for --shards
Error message
Missing value for --shards
What it means
In parseArgs (scripts/test-free-shards.ts:248) the --shards flag must be followed by a value token. If --shards is the last argv token or the next token is missing, it throws. The parsed value is then Number.parseInt'd into shardCount.
Source
Thrown at scripts/test-free-shards.ts:248
shardCount: number;
shardIndex: number | null;
};
function parseCliOptions(argv: string[]): CliOptions {
let dryRun = false;
let listOnly = false;
let windowsOnly = false;
let shardCount = DEFAULT_SHARD_COUNT;
let shardIndex: number | null = null;
for (let index = 0; index < argv.length; index += 1) {
const arg = argv[index];
if (arg === '--dry-run') { dryRun = true; continue; }
if (arg === '--list') { listOnly = true; continue; }
if (arg === '--windows-only') { windowsOnly = true; continue; }
if (arg === '--shards') {
const value = argv[index + 1];
if (!value) throw new Error('Missing value for --shards');
shardCount = Number.parseInt(value, 10);
index += 1;
continue;
}
if (arg === '--shard') {
const value = argv[index + 1];
if (!value) throw new Error('Missing value for --shard');
shardIndex = Number.parseInt(value, 10);
index += 1;
continue;
}
throw new Error(`Unknown argument: ${arg}`);
}
return { dryRun, listOnly, windowsOnly, shardCount, shardIndex };
}
function formatShardSummary(shards: string[][]): string[] {View on GitHub (pinned to 94993f7401)
Solutions
- Append the value: `--shards 4`
- Use a shell default: `--shards ${N:-4}`
- Skip the flag entirely to keep DEFAULT_SHARD_COUNT
Example fix
# before test-free-shards --shards # after test-free-shards --shards 4
Defensive patterns
Strategy: validation
Validate before calling
const i = argv.indexOf('--shards');
if (i !== -1 && argv[i + 1] == null) {
console.error('Missing value for --shards');
process.exit(2);
} Prevention
- Quote CLI args sourced from environment variables
- Use `set -u` in bash to catch unset variables before they reach the CLI
- Provide a shell default: `--shards ${N:-4}`
When it happens
Trigger: Running `test-free-shards --shards` at the end of the command. Shell variable feeding the value being unset and producing no token.
Common situations: Conditionally appending `--shards $N` in a script where N is unset. Trailing flag from a generated argv array.
Related errors
- Missing value for --shard
- Unknown host: ${val}. Use ${ALL_HOST_NAMES.join(', ')}, or a
- Unknown model: ${val}. Use ${ALL_MODEL_NAMES.join(', ')}, or
- Unknown catalog mode: ${val}. Use 'trim' (default) or 'full'
- Unknown explain level: ${val}. Use 'default' or 'terse'.
AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12).
Data as JSON: /api/errors/846addeb0e446908.
Report an issue: GitHub.