affaan-m/ECC · error · Error
${flagName} requires a value
Error message
${flagName} requires a value What it means
Thrown by readArgValue in preview-pack-smoke's arg parser when a value-taking flag (--format, --root) is followed by nothing or by another `--` flag. Same guard pattern as the other ECC scripts: a missing/flag-like value is rejected so the smoke gate never silently treats a flag name as data. This script is the deterministic smoke gate for the ECC 2.0 rc.1 preview pack.
Source
Thrown at scripts/preview-pack-smoke.js:97
];
function usage() {
console.log([
'Usage: node scripts/preview-pack-smoke.js [--format <text|json>] [--root <dir>]',
'',
'Deterministic smoke gate for the ECC 2.0 rc.1 preview pack.',
'',
'Options:',
' --format <text|json> Output format (default: text)',
' --root <dir> Repository root to inspect (default: cwd)',
' --help, -h Show this help',
].join('\n'));
}
function readArgValue(args, index, flagName) {
const value = args[index + 1];
if (!value || value.startsWith('--')) {
throw new Error(`${flagName} requires a value`);
}
return value;
}
function parseArgs(argv) {
const args = argv.slice(2);
const parsed = {
format: 'text',
help: false,
root: path.resolve(process.cwd()),
};
for (let index = 0; index < args.length; index += 1) {
const arg = args[index];
if (arg === '--help' || arg === '-h') {
parsed.help = true;
continue;View on GitHub (pinned to 01e15490f0)
Solutions
- Provide the value right after the flag: `--format json` or `--root /repo`.
- Prefer the `=` form for safety: `--format=json`, `--root=/repo`.
- Validate any templated value is non-empty before assembling the command.
Example fix
# before node scripts/preview-pack-smoke.js --root --format json # after node scripts/preview-pack-smoke.js --root /path/to/repo --format json
Defensive patterns
Strategy: validation
Validate before calling
function ensurePreviewFlagValue(args, index, flagName) {
const value = args[index + 1];
if (!value || value.startsWith('--')) {
throw new Error(`${flagName} requires a value`);
}
return value;
} Type guard
function isFlagValueToken(token) {
return typeof token === 'string' && token.length > 0 && !token.startsWith('--');
} Try / catch
try {
parseArgs(process.argv);
} catch (err) {
if (err.message.endsWith('requires a value')) {
console.error(`${err.message}. Use --flag=value form for safety.`);
process.exit(2);
}
throw err;
} Prevention
- Prefer `--format=json` / `--root=/repo` to dodge this entirely.
- Assert CI-templated values are non-empty before assembling the command.
- This script only accepts --format and --root.
When it happens
Trigger: `--format` as the last token; `--root --format json` (root value missing); a wrapper that conditionally appends a value that resolved empty.
Common situations: CI matrix builds the command from templates and a variable was empty; user edited an example and deleted the value.
Related errors
- Unknown argument: ${arg}
- Invalid format: ${parsed.format}. Use text or json.
- Unknown argument: ${arg}
- Unknown argument: ${arg}
- --timeout-ms must be a positive number
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/65f8d1b1389817bf.
Report an issue: GitHub.