{"record":{"id":"0cea39a52cbd99be","repo":"apache/cassandra","slug":"arguments-for-f-are-json-yaml-only","errorCode":null,"errorMessage":"arguments for -F are json,yaml only.","messagePattern":"arguments for -F are json,yaml only\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/CompactionHistory.java","lineNumber":47,"sourceCode":"@Command(name = \"compactionhistory\", description = \"Print history of compaction\")\npublic class CompactionHistory extends AbstractCommand\n{\n    @Option(paramLabel = \"format\",\n            names = { \"-F\", \"--format\" },\n            description = \"Output format (json, yaml)\")\n    private String outputFormat = \"\";\n\n    @Option(paramLabel = \"human_readable\",\n            names = { \"-H\", \"--human-readable\" },\n            description = \"Display bytes in human readable form, i.e. KiB, MiB, GiB, TiB\")\n    private boolean humanReadable = false;\n\n    @Override\n    public void execute(NodeProbe probe)\n    {\n        if (!outputFormat.isEmpty() && !\"json\".equals(outputFormat) && !\"yaml\".equals(outputFormat))\n        {\n            throw new IllegalArgumentException(\"arguments for -F are json,yaml only.\");\n        }\n        StatsHolder data = new CompactionHistoryHolder(probe, humanReadable);\n        StatsPrinter printer = CompactionHistoryPrinter.from(outputFormat);\n        printer.print(data, probe.output().out);\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":54,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/CompactionHistory.java#L29-L54","documentation":"IllegalArgumentException from CompactionHistory.execute when the -F/--format option is something other than json or yaml. The output format whitelist is enforced at execution time; the default empty value means tabular output.","triggerScenarios":"Running `nodetool compactionhistory -F <value>` with a format other than json or yaml, e.g. -F table, -F txt, -F JSON (case-sensitive).","commonSituations":"Assuming table/plain output formats exist because other nodetool commands support them; shell variable containing an unexpected default value; case mismatch.","solutions":["Use -F json or -F yaml exactly (lowercase).","Omit -F entirely for the default human-readable table output.","Fix any script variable supplying the format."],"exampleFix":"// before\nnodetool compactionhistory -F table\n// after\nnodetool compactionhistory -F yaml","handlingStrategy":"validation","validationCode":"Set<String> allowed = Set.of(\"json\", \"yaml\", \"\");\nif (!allowed.contains(outputFormat))\n    throw new IllegalArgumentException(\"-F must be json or yaml (got: \" + outputFormat + \")\");","typeGuard":null,"tryCatchPattern":"try { printer.print(data, out); }\ncatch (IllegalArgumentException e) { System.err.println(e.getMessage() + \" Valid: -F json | -F yaml\"); System.exit(2); }","preventionTips":["Whitelist format values in scripts calling nodetool compactionhistory.","Formats are lowercase and case-sensitive — never pass 'JSON' or 'YAML'.","Omit -F for the default table output.","Share a common output-format validator across nodetool wrapper scripts."],"tags":["nodetool","cli","validation","output-format"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}