affaan-m/ECC · error · Error
Invalid format: . Use text or json.
Error message
Invalid format: ${parsed.format}. Use text or json. What it means
After parsing, parseArgs validates that the --format value is one of the two supported output formats, text or json. Any other value throws this error before any report generation runs. This is a whitelist check preventing downstream rendering from encountering unknown formats.
Solutions
- Use --format text or --format json exactly (lowercase).
- Fix casing, e.g. --format JSON -> --format json.
- Fix typos in the format value.
- If another format is genuinely needed, extend the whitelist array in parseArgs and the corresponding renderer.
Example fix
// before node scripts/observability-readiness.js --format yaml // after node scripts/observability-readiness.js --format json
Defensive patterns
Strategy: validation
Validate before calling
const i = args.indexOf('--format');
const fmt = i !== -1 ? args[i+1] : 'text';
if (!['text','json'].includes(fmt)) throw new Error(`--format must be 'text' or 'json', got: ${fmt}`); Type guard
const isReportFormat = (v) => v === 'text' || v === 'json';
Try / catch
try {
runObservability(argv);
} catch (err) {
if (err.message.startsWith('Invalid format:')) {
console.error("Use --format text or --format json (lowercase).");
} else throw err;
} Prevention
- Only pass the literal values text or json (lowercase).
- Validate any env-interpolated format variable before passing it.
- Don't assume additional formats (csv/yaml) are supported.
- Centralize report invocation in a helper that hardcodes an allowed format.
When it happens
Trigger: Running with `--format yaml`, `--format table`, or any misspelled value like `--format Json` (case-sensitive check); also --format followed by an unexpected token that slipped through readValue.
Common situations: Assuming more formats are supported (csv, markdown); shell casing differences like JSON vs json; an env-interpolated FORMAT variable holding an unsupported default.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- --host-provider must be anthropic, openai, or unknown
- Invalid --action value
- Invalid
- Invalid format: . Use text, json, or markdown.
- Invalid format: . Use text, json, or markdown.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/08b5d8f2e0edaf4d.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/observability-readiness.js:72
continue;
}
if (arg === '--root') {
parsed.root = path.resolve(readValue(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 fileExists(rootDir, relativePath) {
return fs.existsSync(path.join(rootDir, relativePath));
}
function readText(rootDir, relativePath) {
try {
return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');
} catch (_error) {
return '';
}
}
function safeParseJson(text) {View on GitHub (pinned to 8321021c54)