affaan-m/ECC · error · Error
--write requires --json, --markdown, or --format…
Error message
--write requires --json, --markdown, or --format json|markdown
What it means
parseArgs in scripts/discussion-audit.js refuses to write the plain-text report to a file: --write is only allowed when the format is json or markdown, since the text report is meant for terminal display. Passing --write with default text format throws this combination error.
Solutions
- Add --json or --markdown when using --write, e.g. `--write report.md --markdown`.
- Or pass `--format json --write report.json`.
- If you want the text report saved, pipe stdout: `node scripts/discussion-audit.js > report.txt`.
Example fix
// before node scripts/discussion-audit.js --write report.txt // after node scripts/discussion-audit.js --write report.md --markdown
Defensive patterns
Strategy: validation
Validate before calling
if (argv.includes('--write') && !argv.includes('--json') && !argv.includes('--markdown') && !argv.includes('--format')) {
console.error('--write needs --json or --markdown');
process.exit(1);
} Type guard
function canWrite(argv) {
const fmtIdx = argv.indexOf('--format');
const fmt = fmtIdx !== -1 ? argv[fmtIdx + 1] : (argv.includes('--json') ? 'json' : argv.includes('--markdown') ? 'markdown' : 'text');
return !argv.includes('--write') || fmt !== 'text';
} Try / catch
try {
runAudit(argv);
} catch (e) {
if (e.message.includes('--write requires')) {
console.error('Add --json or --markdown when using --write, or redirect stdout for text.');
} else throw e;
} Prevention
- Pair --write with --json or --markdown by convention in scripts.
- Use stdout redirection if you need the text report saved.
- Encode this rule in any CI wrapper around the audit script.
When it happens
Trigger: Running `node scripts/discussion-audit.js --write report.txt` without also passing --json, --markdown, or --format json|markdown.
Common situations: Trying to save the human-readable text report; forgetting that --write needs a machine format; composing scripts that add --write without adjusting format.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- all overlays must be readable local files
- all takes must be readable local files
- Arguments must not contain NUL bytes.
- asset name must be a simple filename stem (letters, digits…
- At least one guided harness must be selected
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/dcc9d1718b2dd07c.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/discussion-audit.js:149
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');
}
return parsed;
}
function buildReport(options) {
const repos = options.repos.length > 0 ? options.repos : DEFAULT_REPOS;
const repoReports = repos.map(repo => {
try {
return {
repo,
discussions: fetchDiscussionSummary(repo, options),
};
} catch (error) {
return {
repo,
error: error.message,
discussions: emptyDiscussionSummary(),View on GitHub (pinned to 8321021c54)