{"record":{"id":"70af6cca67955cd7","repo":"apache/cassandra","slug":"arguments-for-f-are-json-yaml-only-70af6c","errorCode":null,"errorMessage":"arguments for -F are json,yaml only.","messagePattern":"arguments for -F are json,yaml only\\.","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/TableStats.java","lineNumber":91,"sourceCode":"                        + \"sai_rows_filtered, sai_total_query_timeouts, sai_total_queryable_index_ratio)\")\n    private String sortKey = \"\";\n\n    @Option(paramLabel = \"top\",\n            names = { \"-t\", \"--top\" },\n            description = \"Show only the top K tables for the sort key (specify the number K of tables to be shown\")\n    private int top = 0;\n\n    @Option(paramLabel = \"sstable_location_check\",\n            names = { \"-l\", \"--sstable-location-check\" },\n            description = \"Check whether or not the SSTables are in the correct location.\")\n    private boolean locationCheck = 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\n        if (!sortKey.isEmpty() && !Arrays.asList(StatsTableComparator.supportedSortKeys).contains(sortKey))\n        {\n            throw new IllegalArgumentException(String.format(\"argument for sort must be one of: %s\",\n                                               String.join(\", \", StatsTableComparator.supportedSortKeys)));\n        }\n\n        if (top > 0 && sortKey.isEmpty())\n        {\n            throw new IllegalArgumentException(\"cannot filter top K tables without specifying a sort key.\");\n        }\n\n        if (top < 0)\n        {\n            throw new IllegalArgumentException(\"argument for top must be a positive integer.\");\n        }\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/TableStats.java#L73-L109","documentation":"TableStats accepts an optional -F/--output-format flag that may only be empty (default), 'json', or 'yaml'. Any other value throws IllegalArgumentException before any stats are collected. The check is an explicit allowlist in execute().","triggerScenarios":"Running `nodetool tablestats -F xml` or `-F CSV` (uppercase) or any format string other than exactly json or yaml.","commonSituations":"Assuming other formats (xml, csv, tsv) are supported because other tools support them; passing uppercase JSON/YAML; scripting errors copying the flag from a different nodetool command.","solutions":["Use -F json or -F yaml exactly (lowercase).","Omit -F entirely to get the default human-readable output.","Post-process the default output with awk/jq-style tooling if another format is needed."],"exampleFix":"// before\nnodetool tablestats -F XML\n// after\nnodetool tablestats -F json","handlingStrategy":"validation","validationCode":"if (!outputFormat.isEmpty() && !outputFormat.equals(\"json\") && !outputFormat.equals(\"yaml\"))\n    throw new IllegalArgumentException(\"-F must be json or yaml\");","typeGuard":null,"tryCatchPattern":"try { runNodetool(\"tablestats\", \"-F\", fmt); }\ncatch (IllegalArgumentException e) { if (e.getMessage().contains(\"-F are json,yaml\")) fmt = \"\"; else throw e; }","preventionTips":["Whitelist formats in wrapper scripts: only allow empty, json, or yaml.","Never uppercase format values.","Check `nodetool help tablestats` for supported values per version."],"tags":["nodetool","cli","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"}