apache/cassandra · warning · IllegalArgumentException

arguments for -F are json, yaml, table only.

Error message

arguments for -F are json, yaml, table only.

What it means

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.

Solutions

  1. Use -F json, -F yaml, or -F table (lowercase)
  2. Omit -F entirely to get the default table output
  3. Fix the case in your script (JSON must be lowercase json)

Example fix

// before
nodetool gcstats -F JSON
// after
nodetool gcstats -F json
Defensive patterns

Strategy: validation

Validate before calling

if [ -n "$FMT" ] && [ "$FMT" != "json" ] && [ "$FMT" != "yaml" ] && [ "$FMT" != "table" ]; then echo "bad -F $FMT"; exit 1; fi

Type guard

const valid = (f) => ['json','yaml','table'].includes(f);

Try / catch

try { printer.print(); } catch (IllegalArgumentException e) { usage("-F must be json, yaml or table"); }

Prevention

When it happens

Trigger: Running `nodetool gcstats -F xml` or any unsupported format string, or invoking GcStats programmatically with outputFormat set to something other than json/yaml/table.

Common situations: Scripts copying -F xml from other tools; typos like -F JSON (case-sensitive check); blank vs non-blank format handling confusion.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/tools/nodetool/GcStats.java:44

@Command(name = "gcstats", description = "Print GC Statistics")
public class GcStats extends AbstractCommand
{
    @Option(paramLabel = "format",
            names = { "-F", "--format" },
            description = "Output format (json, yaml, table)")
    private String outputFormat = "";

    @Option(paramLabel = "human_readable",
            names = { "-H", "--human-readable" },
            description = "Display gcstats with human-readable units")
    private boolean humanReadable = false;

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

        GcStatsPrinter.from(outputFormat).print(new GcStatsHolder(probe, humanReadable), probe.output().out);
    }
}

View on GitHub (pinned to 88fd0f6a0e)