affaan-m/ECC · error · Error
Invalid format: ${parsed.format}. Use text, json, or markdow
Error message
Invalid format: ${parsed.format}. Use text, json, or markdown. What it means
Thrown after the parse loop in platform-audit when `parsed.format` is not one of text/json/markdown. Format is set by --format, --json (forces json), or --markdown (forces markdown), and is lowercased on input; this guard catches unsupported values, empty strings, or a misspelled format.
Source
Thrown at scripts/platform-audit.js:206
parsed.thresholds.maxDirtyFiles = parseIntegerFlag(arg.slice('--max-dirty-files='.length), '--max-dirty-files');
continue;
}
if (arg === '--use-env-github-token') {
parsed.useEnvGithubToken = true;
continue;
}
if (arg === '--exit-code') {
parsed.exitCode = true;
continue;
}
throw new Error(`Unknown argument: ${arg}`);
}
if (!['text', 'json', 'markdown'].includes(parsed.format)) {
throw new Error(`Invalid format: ${parsed.format}. Use text, json, or markdown.`);
}
if (parsed.writePath && parsed.format === 'text') {
throw new Error('--write requires --json, --markdown, or --format json|markdown');
}
parsed.allowUntracked = parsed.allowUntracked.map(normalizeRelativePrefix);
return parsed;
}
function normalizeRelativePrefix(value) {
return String(value || '')
.replace(/\\/g, '/')
.replace(/^\.\/+/, '')
.replace(/\/+$/, '') + (String(value || '').endsWith('/') ? '/' : '');
}
View on GitHub (pinned to 01e15490f0)
Solutions
- Use one of the supported values: `--format json` (or `--json` / `--markdown`).
- If the value is env-supplied, trim and lowercase it before passing.
- Remember `text` is the default — omit --format entirely if human-readable output is fine.
Example fix
# before node scripts/platform-audit.js --format yaml # after node scripts/platform-audit.js --format json
Defensive patterns
Strategy: validation
Validate before calling
const VALID_FORMATS = new Set(['text', 'json', 'markdown']);
function normalizeFormat(raw) {
const f = String(raw || '').trim().toLowerCase();
if (!VALID_FORMATS.has(f)) {
throw new Error(`Invalid format: ${f}. Use text, json, or markdown.`);
}
return f;
} Type guard
function isPlatformAuditFormat(value) {
return typeof value === 'string' && ['text','json','markdown'].includes(value.trim().toLowerCase());
} Try / catch
try {
parseArgs(process.argv);
} catch (err) {
if (err.message.startsWith('Invalid format')) {
console.error('Supported formats: text (default), json, markdown.');
process.exit(2);
}
throw err;
} Prevention
- Use --json or --markdown shortcuts to avoid typos in --format.
- Trim and lowercase env-supplied format strings.
- Remember text is the default — omit the flag if unsure.
When it happens
Trigger: `--format yaml`, `--format HTML`, `--format ''`, or a downstream consumer expecting a format this version does not emit.
Common situations: User assumes a format exists that was never added; env-derived format string with trailing whitespace/newline not trimmed; copy from documentation of a fork.
Related errors
- --write requires --json, --markdown, or --format json|markdo
- Invalid format: ${parsed.format}. Use text or json.
- ${flagName} requires a value
- Invalid ${flagName}: ${value}
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/3f9c4e405b3d5899.
Report an issue: GitHub.