{"record":{"id":"23f24c791b4d4656","repo":"affaan-m/ECC","slug":"write-requires-json-or-markdown","errorCode":null,"errorMessage":"--write requires --json or --markdown","messagePattern":"--write requires --json or --markdown","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/status.js","lineNumber":470,"sourceCode":"      }),\n    };\n    payload.githubCoordination = summarizeGithubCoordination(payload.workItems);\n\n    if (options.json) {\n      const output = `${JSON.stringify(payload, null, 2)}\\n`;\n      if (options.writePath) {\n        writeOutput(options.writePath, output);\n      }\n      process.stdout.write(output);\n    } else if (options.markdown) {\n      const output = renderMarkdown(payload);\n      if (options.writePath) {\n        writeOutput(options.writePath, output);\n      }\n      process.stdout.write(output);\n    } else {\n      if (options.writePath) {\n        throw new Error('--write requires --json or --markdown');\n      }\n      printHuman(payload);\n    }\n\n    if (options.exitCode && payload.readiness.status !== 'ok') {\n      process.exitCode = 2;\n    }\n  } catch (error) {\n    console.error(`Error: ${error.message}`);\n    process.exit(1);\n  } finally {\n    if (store) {\n      store.close();\n    }\n  }\n}\n\nif (require.main === module) {","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/status.js#L452-L488","documentation":"Thrown by scripts/status.js during output dispatch (after the state store has been queried) when --write was supplied but neither --json nor --markdown was selected. --write persists the rendered machine format to disk, and the human-readable console output (the default branch) is not a stable format worth writing to a file, so the combination is rejected. Unlike the parse-time errors, this fires late, after the database query succeeds.","triggerScenarios":"`node scripts/status.js --write report.txt` with no format flag; a wrapper that always sets --write but only conditionally sets --json/--markdown and hits the branch where neither is set.","commonSituations":"Assuming --write implies a default format; migrating a command that previously wrote human text to a file; a script that builds flags in separate conditionals and the format flag was skipped.","solutions":["Add --json or --markdown alongside --write: `node scripts/status.js --markdown --write status.md`.","If you only want on-screen human output, remove --write.","Restructure the wrapper so the format flag and --write are set together in the same conditional branch."],"exampleFix":"// before\nnode scripts/status.js --write /tmp/status.txt\n\n// after\nnode scripts/status.js --json --write /tmp/status.json","handlingStrategy":"validation","validationCode":"// Enforce: --write only when a format flag is also present\nfunction buildStatusArgs(opts) {\n  const args = [];\n  if (opts.format === 'json' || opts.format === 'markdown') {\n    args.push(`--${opts.format}`);\n  } else {\n    return args; // human mode, no --write allowed\n  }\n  if (opts.outFile) args.push('--write', opts.outFile);\n  return args;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --write as subordinate to a format flag; never emit it independently.","Document that the human view is console-only and cannot be redirected via --write.","Add a unit test asserting --write without a format flag is rejected."],"tags":["cli","output-format","conflict","status","filesystem"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}