apache/cassandra · error · java.lang.IllegalArgumentException

arguments for -F are json,yaml only.

Error message

arguments for -F are json,yaml only.

What it means

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().

Solutions

  1. Use -F json or -F yaml exactly (lowercase).
  2. Omit -F entirely to get the default human-readable output.
  3. Post-process the default output with awk/jq-style tooling if another format is needed.

Example fix

// before
nodetool tablestats -F XML
// after
nodetool tablestats -F json
Defensive patterns

Strategy: validation

Validate before calling

if (!outputFormat.isEmpty() && !outputFormat.equals("json") && !outputFormat.equals("yaml"))
    throw new IllegalArgumentException("-F must be json or yaml");

Try / catch

try { runNodetool("tablestats", "-F", fmt); }
catch (IllegalArgumentException e) { if (e.getMessage().contains("-F are json,yaml")) fmt = ""; else throw e; }

Prevention

When it happens

Trigger: Running `nodetool tablestats -F xml` or `-F CSV` (uppercase) or any format string other than exactly json or yaml.

Common situations: 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.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/70af6cca67955cd7. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/tools/nodetool/TableStats.java:91

                        + "sai_rows_filtered, sai_total_query_timeouts, sai_total_queryable_index_ratio)")
    private String sortKey = "";

    @Option(paramLabel = "top",
            names = { "-t", "--top" },
            description = "Show only the top K tables for the sort key (specify the number K of tables to be shown")
    private int top = 0;

    @Option(paramLabel = "sstable_location_check",
            names = { "-l", "--sstable-location-check" },
            description = "Check whether or not the SSTables are in the correct location.")
    private boolean locationCheck = false;

    @Override
    public void execute(NodeProbe probe)
    {
        if (!outputFormat.isEmpty() && !"json".equals(outputFormat) && !"yaml".equals(outputFormat))
        {
            throw new IllegalArgumentException("arguments for -F are json,yaml only.");
        }

        if (!sortKey.isEmpty() && !Arrays.asList(StatsTableComparator.supportedSortKeys).contains(sortKey))
        {
            throw new IllegalArgumentException(String.format("argument for sort must be one of: %s",
                                               String.join(", ", StatsTableComparator.supportedSortKeys)));
        }

        if (top > 0 && sortKey.isEmpty())
        {
            throw new IllegalArgumentException("cannot filter top K tables without specifying a sort key.");
        }

        if (top < 0)
        {
            throw new IllegalArgumentException("argument for top must be a positive integer.");
        }

View on GitHub (pinned to 88fd0f6a0e)