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 release-approval-gate when `parsed.format` is not `text` or `json`. This gate, like preview-pack-smoke, supports only two output formats: text (default, human-readable verdict) and json (machine-parseable for CI). Set via --format or forced to json by --json.
Source
Thrown at scripts/release-approval-gate.js:162
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`: `--format json` or `--json`.
- For markdown reports use platform-audit, which supports it.
- Trim and lowercase any env-supplied format before forwarding.
Example fix
# before node scripts/release-approval-gate.js --format markdown # after node scripts/release-approval-gate.js --format json
Defensive patterns
Strategy: validation
Validate before calling
function normalizeGateFormat(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 isGateFormat(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('release-approval-gate supports only text or json. Use --json for JSON.');
process.exit(2);
}
throw err;
} Prevention
- Use --json shortcut rather than typing --format json.
- Do not assume markdown support — use platform-audit for markdown.
- Trim/lowercase env-supplied format values before forwarding.
When it happens
Trigger: `--format markdown`, `--format yaml`, `--format ''`, or assuming markdown support parity with platform-audit.
Common situations: User copies a --format value from platform-audit docs; env-derived format with whitespace/newline; expecting parity across all ECC gates.
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
- Invalid format: ${parsed.format}. Use text or json.
- ${flagName} requires a value
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/ff43e797abc2a0a1.
Report an issue: GitHub.