affaan-m/ECC · error · Error
Unknown argument: ${arg}
Error message
Unknown argument: ${arg} What it means
The argument parser in supply-chain-advisory-sources.js only recognizes a fixed set of flags: --help, -h, --json, --refresh, --strict-refresh, --generated-at, --timeout-ms, and --write. Any token that does not match one of these falls through to the else branch and throws. This is a strict fail-fast parser design — no positional arguments or unknown flags are tolerated.
Source
Thrown at scripts/ci/supply-chain-advisory-sources.js:393
} else if (arg === '--json') {
options.json = true;
} else if (arg === '--refresh') {
options.refresh = true;
} else if (arg === '--strict-refresh') {
options.strictRefresh = true;
options.refresh = true;
} else if (arg === '--generated-at') {
options.generatedAt = argv[++i];
} else if (arg === '--timeout-ms') {
options.timeoutMs = Number(argv[++i]);
if (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0) {
throw new Error('--timeout-ms must be a positive number');
}
} else if (arg === '--write') {
options.writePath = argv[++i];
if (!options.writePath) throw new Error('--write requires a path');
} else {
throw new Error(`Unknown argument: ${arg}`);
}
}
return options;
}
function printHelp() {
console.log(`Usage: node scripts/ci/supply-chain-advisory-sources.js [options]
Build the active supply-chain advisory source report used by the scheduled
watch workflow and Linear ITO-57 status updates.
Options:
--json Emit JSON instead of text
--refresh Check source URLs and record warning status
--strict-refresh Fail when a refreshed source URL returns a warning
--generated-at <ts> Override the report timestamp
--timeout-ms <n> Per-source refresh timeout (default: ${DEFAULT_TIMEOUT_MS})
--write <path> Write the report to a fileView on GitHub (pinned to 01e15490f0)
Solutions
- Run the script with --help to list all accepted flags and compare against what you passed
- Check for typos in flag names (e.g. --strict-refresh vs --stric-refresh)
- If migrating from an older version, consult the changelog or printHelp() output for renamed flags
Example fix
// before node scripts/ci/supply-chain-advisory-sources.js --output report.json // after node scripts/ci/supply-chain-advisory-sources.js --write report.json
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate all arguments against the accepted set before invoking parseArgs
const ACCEPTED = new Set(['--help', '-h', '--json', '--refresh', '--strict-refresh', '--generated-at', '--timeout-ms', '--write']);
const argv = process.argv.slice(2);
for (let i = 0; i < argv.length; i++) {
const arg = argv[i];
if (!ACCEPTED.has(arg) && !arg.startsWith('-')) continue; // positional args are not expected but skip non-flag tokens
if (!ACCEPTED.has(arg) && arg.startsWith('-')) {
console.error(`Unknown argument: ${arg}`);
printHelp();
process.exit(1);
}
} Try / catch
// Catch unknown-argument errors and show help
try {
const options = parseArgs(process.argv.slice(2));
} catch (error) {
if (error.message.startsWith('Unknown argument:')) {
console.error(error.message);
printHelp();
process.exit(2);
}
throw error;
} Prevention
- Run the script with --help to discover accepted flags before constructing commands
- When upgrading ECC versions, re-check the help output for renamed or removed flags
- In CI, pin the ECC version and document the exact flags used in comments
When it happens
Trigger: Passing a flag from a different script by mistake (e.g. --output instead of --write), using a removed flag from an older version, or a typo such as --stric-refresh instead of --strict-refresh. Also triggered by passing positional arguments since the parser expects only flags.
Common situations: Upgrading the script to a new version that renamed or removed flags; CI workflows with stale argument lists; copy-pasting commands from outdated documentation or blog posts.
Related errors
- --write requires a path
- Unknown argument: ${arg}
- --timeout-ms must be a positive number
- Unknown argument: ${arg}
- Invalid ${flag}: expected a single cache path segment
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/accbc46fc8d2f910.
Report an issue: GitHub.