affaan-m/ECC · error · Error
Unknown argument
Error message
Unknown argument: ${arg} What it means
parseArgs in scripts/harness-adapter-compliance.js accepts a fixed set of flags; any argument that does not match one of the known prefixes hits the final throw `Unknown argument: <arg>`. The parser is strict: it refuses unknown flags rather than ignoring them.
Solutions
- Remove or correct the offending argument; run the script with no args/--help to list supported flags.
- Match the exact prefix the parser checks (e.g. --root= with equals sign, not --root <value>).
- Compare against a working invocation of the same script (CI config, package.json scripts, docs).
- If you need a new flag, extend parseArgs rather than hoping it is accepted.
Example fix
// before node scripts/harness-adapter-compliance.js --root ./sub --verbose // after node scripts/harness-adapter-compliance.js --root=./sub
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN = /^--(root=|format=|json$|text$|markdown$)/; // adjust to actual flag list
const bad = argv.filter((a) => a.startsWith('--') && !KNOWN.test(a));
if (bad.length) throw new Error(`Unknown argument(s): ${bad.join(', ')}`); Type guard
const isKnownFlag = (arg) =>
arg.startsWith('--root=') || arg.startsWith('--format=') || arg === '--help'; Try / catch
try {
const parsed = parseArgs(process.argv);
} catch (e) {
if (e.message.startsWith('Unknown argument:')) {
console.error(e.message + ' — see --help for supported flags');
process.exit(2);
}
throw e;
} Prevention
- Run the script with --help (or no args) before adopting new flags.
- Use = syntax (--root=dir) as the parser expects prefix matching.
- Don't reuse flag lines from other scripts without checking they exist here.
- When flags change in the parser, update package.json scripts and CI configs in the same commit.
When it happens
Trigger: Passing a flag the script does not know (e.g. --verbose, --out=file), using a space-separated value after a flag that only supports = syntax, or misspelling a supported flag (--rooot=...).
Common situations: Reusing command lines from other ECC scripts with different flag sets; shell aliases appending extra flags; typos in flag names; assuming an older version supported a flag that was removed.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- must be a positive integer
- Invalid
- Unknown argument
- all overlays must be readable local files
- all takes must be readable local files
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/3e787f1f5639c825.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/harness-adapter-compliance.js:56
}
if (arg.startsWith('--format=')) {
parsed.format = arg.slice('--format='.length).toLowerCase();
continue;
}
if (arg === '--root') {
parsed.root = path.resolve(args[index + 1] || process.cwd());
index += 1;
continue;
}
if (arg.startsWith('--root=')) {
parsed.root = path.resolve(arg.slice('--root='.length));
continue;
}
throw new Error(`Unknown argument: ${arg}`);
}
if (!['text', 'json', 'markdown'].includes(parsed.format)) {
throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);
}
parsed.root = path.resolve(parsed.root);
return parsed;
}
function printHelp() {
console.log([
'Usage: node scripts/harness-adapter-compliance.js [options]',
'',
'Validate or render the ECC harness adapter compliance scorecard.',
'',
'Options:',
' --check Fail if adapter records or docs are out of sync',View on GitHub (pinned to 8321021c54)