affaan-m/ECC · error · Error
Invalid format: ${parsed.format}. Use text or json.
Error message
Invalid format: ${parsed.format}. Use text or json. What it means
Thrown after the parse loop in preview-pack-smoke when `parsed.format` is not `text` or `json`. Unlike platform-audit this script supports only two formats (no markdown), since its job is a pass/fail smoke signal best consumed as text or JSON. Set by --format or forced to json by --json.
Source
Thrown at scripts/preview-pack-smoke.js:144
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) {
return fs.existsSync(path.join(rootDir, relativePath));
}
function safeParseJson(text) {View on GitHub (pinned to 01e15490f0)
Solutions
- Use `text` (default) or `json` only: `--format json` or `--json`.
- If you need markdown, use platform-audit instead — preview-pack-smoke does not emit it.
- Trim/lowercase any env-supplied format before passing.
Example fix
# before node scripts/preview-pack-smoke.js --format markdown # after node scripts/preview-pack-smoke.js --format json
Defensive patterns
Strategy: validation
Validate before calling
function normalizePreviewFormat(raw) {
const f = String(raw || '').trim().toLowerCase();
if (!['text','json'].includes(f)) {
throw new Error(`Invalid format: ${f}. Use text or json.`);
}
return f;
} Type guard
function isPreviewFormat(value) {
return typeof value === 'string' && ['text','json'].includes(value.trim().toLowerCase());
} Try / catch
try {
parseArgs(process.argv);
} catch (err) {
if (err.message.startsWith('Invalid format')) {
console.error('preview-pack-smoke supports only text or json. Use --json for JSON.');
process.exit(2);
}
throw err;
} Prevention
- Use --json shortcut instead of typing --format json.
- Do not assume markdown parity with platform-audit.
- Trim/lowercase env-supplied format values.
When it happens
Trigger: `--format markdown`, `--format yaml`, `--format ''`, or assuming markdown parity with platform-audit.
Common situations: User assumes all ECC audit scripts share the same format set; copy-paste from platform-audit docs; env-derived format string not trimmed.
Related errors
- Invalid format: ${parsed.format}. Use text or json.
- Invalid format: ${parsed.format}. Use text, json, or markdow
- --write requires --json, --markdown, or --format json|markdo
- ${flagName} requires a value
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/976178d418bf5ae5.
Report an issue: GitHub.