affaan-m/ECC · error
Invalid format: ${parsed.format}. Use text or json.
Error message
Invalid format: ${parsed.format}. Use text or json. What it means
After argument parsing finishes, harness-audit.js verifies that parsed.format is one of 'text' or 'json' (the default is 'text'). Any other value, including an empty string from `--format=`, is rejected. The check is lowercased so `JSON` is accepted but `yaml`/`csv`/`xml` are not.
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 01e15490f0)
Solutions
- Use --format=text or --format=json
- Omit --format entirely to accept the default text output
- Pipe text/json output through a converter if you need another format downstream
Example fix
// before node scripts/harness-audit.js --format=yaml // after node scripts/harness-audit.js --format=json
Defensive patterns
Strategy: validation
Validate before calling
const VALID_FORMATS = new Set(['text','json']);
const fmt = (parsed.format || 'text').toLowerCase();
if (!VALID_FORMATS.has(fmt)) {
throw new Error(`Unsupported format '${fmt}'. Use text or json.`);
} Type guard
function isValidFormat(value) {
return typeof value === 'string'
&& ['text','json'].includes(value.toLowerCase());
} Try / catch
try { runAudit(); }
catch (err) {
if (/^Invalid format:/.test(err.message)) {
console.error(err.message);
process.exit(2);
}
throw err;
} Prevention
- Default to omitting --format; text is the default
- Whitelist the format string in wrapper scripts before forwarding it
When it happens
Trigger: Running --format=yaml, --format=csv, --format xml, or --format= (empty value after the equals sign).
Common situations: Expecting the auditor to emit a format another tool supports, a CI script parameterized with an unsupported format string, or a typo in a wrapper script.
Related errors
- 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.
- Invalid format: ${parsed.format}. Use text or json.
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/6d847d6d5a0fe6f2.
Report an issue: GitHub.