{"record":{"id":"a33ed36841f3dd26","repo":"apache/cassandra","slug":"arguments-for-f-are-json-yaml-table-only","errorCode":null,"errorMessage":"arguments for -F are json, yaml, table only.","messagePattern":"arguments for -F are json, yaml, table only\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/tools/nodetool/GcStats.java","lineNumber":44,"sourceCode":"\n@Command(name = \"gcstats\", description = \"Print GC Statistics\")\npublic class GcStats extends AbstractCommand\n{\n    @Option(paramLabel = \"format\",\n            names = { \"-F\", \"--format\" },\n            description = \"Output format (json, yaml, table)\")\n    private String outputFormat = \"\";\n\n    @Option(paramLabel = \"human_readable\",\n            names = { \"-H\", \"--human-readable\" },\n            description = \"Display gcstats with human-readable units\")\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) && !\"table\".equals(outputFormat))\n            throw new IllegalArgumentException(\"arguments for -F are json, yaml, table only.\");\n\n        GcStatsPrinter.from(outputFormat).print(new GcStatsHolder(probe, humanReadable), probe.output().out);\n    }\n}","sourceCodeStart":26,"sourceCodeEnd":48,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/GcStats.java#L26-L48","documentation":"GcStats validates the -F/--output-format flag before printing. If the format is not exactly 'json', 'yaml', or 'table', it throws this IllegalArgumentException. It is a pure client-side argument validation error in nodetool.","triggerScenarios":"Running `nodetool gcstats -F xml` or any unsupported format string, or invoking GcStats programmatically with outputFormat set to something other than json/yaml/table.","commonSituations":"Scripts copying -F xml from other tools; typos like -F JSON (case-sensitive check); blank vs non-blank format handling confusion.","solutions":["Use -F json, -F yaml, or -F table (lowercase)","Omit -F entirely to get the default table output","Fix the case in your script (JSON must be lowercase json)"],"exampleFix":"// before\nnodetool gcstats -F JSON\n// after\nnodetool gcstats -F json","handlingStrategy":"validation","validationCode":"if [ -n \"$FMT\" ] && [ \"$FMT\" != \"json\" ] && [ \"$FMT\" != \"yaml\" ] && [ \"$FMT\" != \"table\" ]; then echo \"bad -F $FMT\"; exit 1; fi","typeGuard":"const valid = (f) => ['json','yaml','table'].includes(f);","tryCatchPattern":"try { printer.print(); } catch (IllegalArgumentException e) { usage(\"-F must be json, yaml or table\"); }","preventionTips":["Use lowercase format values","Omit -F for default table output","Centralize format validation in wrappers"],"tags":["nodetool","cli","argument-validation"],"backgroundTag":"invalid-cli-argument","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"}