affaan-m/ECC · error · Error
Invalid format: . Use text or json.
Error message
Invalid format: ${parsed.format}. Use text or json. What it means
parseArgs in scripts/harness-audit.js validates that the --format value is one of exactly two supported output formats: 'text' or 'json'. Any other value (case-sensitive) fails so downstream rendering only has to handle known formats.
Solutions
- Use exactly `--format=text` or `--format=json` (lowercase)
- If a variable supplies the value, echo it first to confirm it is non-empty and lowercase
- Omit --format entirely to use the default
- Normalize with toLowerCase() in the calling script
Example fix
// before node scripts/harness-audit.js --format=JSON // after node scripts/harness-audit.js --format=json
Defensive patterns
Strategy: validation
Validate before calling
const format = (process.env.AUDIT_FORMAT || 'text').toLowerCase();
if (!['text', 'json'].includes(format)) throw new Error(`Invalid format: ${format}`); Type guard
const isAuditFormat = (v) => v === 'text' || v === 'json';
Try / catch
try {
parseArgs(args);
} catch (err) {
if (String(err.message).startsWith('Invalid format:')) {
console.error(`${err.message} (accepted: text, json)`);
process.exit(2);
}
throw err;
} Prevention
- Always lowercase --format values in wrapper scripts
- Validate env-supplied values before interpolation into the command line
- Default to omitting --format unless a non-default output is needed
When it happens
Trigger: Calling `node scripts/harness-audit.js --format=markdown`, `--format=JSON` (uppercase rejected), or `--format=` (empty value after the equals sign).
Common situations: Case mismatch (JSON vs json), passing a format supported by another tool, scripting with a variable that is empty or unset.
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 format: . Use text, json, or markdown.
- 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/6d847d6d5a0fe6f2.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/harness-audit.js:128
if (arg.startsWith('--scope=')) {
parsed.scope = normalizeScope(arg.split('=')[1]);
continue;
}
if (arg.startsWith('--root=')) {
parsed.root = path.resolve(arg.slice('--root='.length));
continue;
}
if (arg.startsWith('-')) {
throw new Error(`Unknown argument: ${arg}`);
}
parsed.scope = normalizeScope(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) {
return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');
}
function countFiles(rootDir, relativeDir, extension) {
const dirPath = path.join(rootDir, relativeDir);
if (!fs.existsSync(dirPath)) {
return 0;
}View on GitHub (pinned to 8321021c54)