affaan-m/ECC · error · Error
Unknown argument: ${arg}
Error message
Unknown argument: ${arg} What it means
Thrown at the end of preview-pack-smoke's parseArgs loop when a token matched none of the recognized flags (--help/-h, --format(+==), --json, --root(+==)). The parser is intentionally strict because this is a deterministic smoke gate: unrecognized input would make the result non-reproducible.
Source
Thrown at scripts/preview-pack-smoke.js:140
}
if (arg.startsWith('--format=')) {
parsed.format = arg.slice('--format='.length).toLowerCase();
continue;
}
if (arg === '--root') {
parsed.root = path.resolve(readArgValue(args, index, arg));
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'].includes(parsed.format)) {
throw new Error(`Invalid format: ${parsed.format}. Use text or json.`);
}
return parsed;
}
function readText(rootDir, relativePath) {
try {
return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');
} catch (_error) {
return '';
}
}
function fileExists(rootDir, relativePath) {View on GitHub (pinned to 01e15490f0)
Solutions
- Run `--help` to see the two accepted value flags for this script.
- Use `--root=<dir>` to pass the repo root; this script only takes --format and --root.
- Quote arguments and verify no shell expansion injected stray tokens.
Example fix
# before node scripts/preview-pack-smoke.js --fromat json # after node scripts/preview-pack-smoke.js --format json
Defensive patterns
Strategy: validation
Validate before calling
const PREVIEW_FLAGS = new Set(['--help','-h','--format','--json','--root']);
function isPreviewFlag(token) {
const base = token.split('=')[0];
return PREVIEW_FLAGS.has(base);
} Type guard
function isKnownPreviewFlag(token) {
const base = token.startsWith('--') ? token.split('=')[0] : token;
return PREVIEW_FLAGS.has(base);
} Try / catch
try {
parseArgs(process.argv);
} catch (err) {
if (err.message.startsWith('Unknown argument')) {
console.error(`${err.message}. preview-pack-smoke only accepts --format and --root.`);
process.exit(2);
}
throw err;
} Prevention
- Only --format and --root are valid here; do not copy flags from other scripts.
- Run --help to confirm the accepted surface.
- Quote path arguments to avoid token splitting.
When it happens
Trigger: A typo such as `--fromat`; passing a positional path instead of `--root`; a flag from a different script copied in; shell glob inserting an unexpected token.
Common situations: User copies flags from platform-audit (which has many more) into preview-pack-smoke; version mismatch where a flag was renamed.
Related errors
- ${flagName} requires a value
- 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/ead6c0116342719c.
Report an issue: GitHub.