apache/cassandra · error · java.lang.IllegalArgumentException

Cannot specify both --sai-only and --include-sai

Error message

Cannot specify both --sai-only and --include-sai

What it means

nodetool verify supports two mutually exclusive SAI-related flags: --sai-only (verify only SAI indexes) and --include-sai (verify non-SAI plus SAI). Passing both is ambiguous, so execute() throws IllegalArgumentException before starting verification. No verification runs.

Solutions

  1. Pass only one flag: --sai-only to verify just SAI indexes, --include-sai to add SAI to the normal verify scope.
  2. Remove both flags for the default (non-SAI) verify behavior.
  3. Fix the calling script/template so the two options cannot both resolve to true.

Example fix

// before
nodetool verify --sai-only --include-sai myks mytable
// after
nodetool verify --include-sai myks mytable
Defensive patterns

Strategy: validation

Validate before calling

if (saiOnly && includeSai)
    throw new IllegalArgumentException("--sai-only and --include-sai are mutually exclusive");

Try / catch

try { runVerify(args); }
catch (IllegalArgumentException e) { if (e.getMessage().contains("--sai-only and --include-sai")) { /* fix flags and retry */ } else throw e; }

Prevention

When it happens

Trigger: `nodetool verify --sai-only --include-sai <keyspace> <table>` in a single invocation.

Common situations: Scripts accumulating flags from merged examples; users unsure which flag they need and passing both to be safe; templated commands where both options were parameterized to true.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/tools/nodetool/Verify.java:104

    @Option(paramLabel = "include_sai",
            names = { "-i", "--include-sai"},
            description = "Include SAI index verification along with data files")
    private boolean includeSai = false;

    @Override
    public void execute(NodeProbe probe)
    {
        args = concatArgs(keyspace, tables);
        PrintStream out = probe.output().out;
        if (!overrideDisable)
        {
            out.println("verify is disabled unless a [-f|--force] override flag is provided. See CASSANDRA-9947 and CASSANDRA-17017 for details.");
            System.exit(1);
        }

        if (onlySai && includeSai)
            throw new IllegalArgumentException("Cannot specify both --sai-only and --include-sai");

        List<String> keyspaces = parseOptionalKeyspace(args, probe);
        String[] tableNames = parseOptionalTables(args);

        if (checkOwnsTokens && !extendedVerify)
        {
            out.println("Token verification requires --extended-verify");
            // if System.exit gets removed, make sure to update org.apache.cassandra.distributed.test.NodeToolTest.testNodetoolSystemExit
            System.exit(1);
        }

        for (String keyspace : keyspaces)
        {
            try
            {
                probe.verify(out, extendedVerify, checkVersion, diskFailurePolicy, mutateRepairStatus, checkOwnsTokens, quick, onlySai, includeSai, keyspace, tableNames);
            } catch (Exception e)
            {

View on GitHub (pinned to 88fd0f6a0e)