apache/cassandra · error · IllegalArgumentException

arguments for -F are json,yaml only.

Error message

arguments for -F are json,yaml only.

What it means

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.

Solutions

  1. Use -F json or -F yaml exactly (lowercase).
  2. Omit -F entirely for the default human-readable table output.
  3. Fix any script variable supplying the format.

Example fix

// before
nodetool compactionhistory -F table
// after
nodetool compactionhistory -F yaml
Defensive patterns

Strategy: validation

Validate before calling

Set<String> allowed = Set.of("json", "yaml", "");
if (!allowed.contains(outputFormat))
    throw new IllegalArgumentException("-F must be json or yaml (got: " + outputFormat + ")");

Try / catch

try { printer.print(data, out); }
catch (IllegalArgumentException e) { System.err.println(e.getMessage() + " Valid: -F json | -F yaml"); System.exit(2); }

Prevention

When it happens

Trigger: Running `nodetool compactionhistory -F <value>` with a format other than json or yaml, e.g. -F table, -F txt, -F JSON (case-sensitive).

Common situations: Assuming table/plain output formats exist because other nodetool commands support them; shell variable containing an unexpected default value; case mismatch.

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/0cea39a52cbd99be. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/tools/nodetool/CompactionHistory.java:47

@Command(name = "compactionhistory", description = "Print history of compaction")
public class CompactionHistory extends AbstractCommand
{
    @Option(paramLabel = "format",
            names = { "-F", "--format" },
            description = "Output format (json, yaml)")
    private String outputFormat = "";

    @Option(paramLabel = "human_readable",
            names = { "-H", "--human-readable" },
            description = "Display bytes in human readable form, i.e. KiB, MiB, GiB, TiB")
    private boolean humanReadable = 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.");
        }
        StatsHolder data = new CompactionHistoryHolder(probe, humanReadable);
        StatsPrinter printer = CompactionHistoryPrinter.from(outputFormat);
        printer.print(data, probe.output().out);
    }
}

View on GitHub (pinned to 88fd0f6a0e)