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 by parseArgs in scripts/operator-readiness-dashboard.js after parsing, when the resolved format is not one of text, json, or markdown. Format is set by --json (sets 'json'), --markdown (sets 'markdown'), or --format/--format= directly. An unrecognized --format value or a default-then-overwritten path lands here.
Source
Thrown at scripts/operator-readiness-dashboard.js:218
index += 1;
continue;
}
if (arg.startsWith('--generated-at=')) {
parsed.generatedAt = arg.slice('--generated-at='.length);
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).filter(Boolean);
return parsed;
}
function readText(rootDir, relativePath) {
try {
return fs.readFileSync(path.join(rootDir, relativePath), 'utf8');
} catch (_error) {
return '';
}
}View on GitHub (pinned to 01e15490f0)
Solutions
- Use one of: --json, --markdown, or omit the flag (defaults to text).
- If using --format explicitly, pass a lowercase 'text', 'json', or 'markdown'.
- Quote and validate shell variables so empty values are caught before invocation.
Example fix
// before node scripts/operator-readiness-dashboard.js --format yaml // after node scripts/operator-readiness-dashboard.js --format markdown
Defensive patterns
Strategy: validation
Validate before calling
const DASH_FORMATS = new Set(['text', 'json', 'markdown']);
function normalizeDashFormat(raw) {
const f = String(raw || '').toLowerCase();
if (!DASH_FORMATS.has(f)) throw new Error(`Unsupported format '${raw}'. Use text, json, or markdown.`);
return f;
} Type guard
function isDashFormat(value) {
return typeof value === 'string' && DASH_FORMATS.has(value.toLowerCase());
} Prevention
- Note this script does not lowercase --format itself; pass lowercase to be safe.
- Prefer the dedicated --json / --markdown toggles over --format when possible.
- Validate format before building argv so CI fails at the configuration stage.
When it happens
Trigger: Passing `--format yaml`, `--format html`, or `--format csv`. Passing `--format=` with an empty value. Note the format value is NOT lowercased here (unlike observability-readiness.js), so `JSON` would also be rejected.
Common situations: Case mismatch (`JSON` vs `json`); assuming the format strings of another tool; an empty shell variable expanding into `--format=`.
Related errors
- ${flagName} requires a value
- Invalid ${flagName}: ${value}
- Unknown argument: ${arg}
- --write requires --json, --markdown, or --format json|markdo
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/5261260156866f5e.
Report an issue: GitHub.