apache/cassandra · error · IllegalArgumentException

onlySai and includeSai both cannot be true at a time.

Error message

onlySai and includeSai both cannot be true at a time.

What it means

IVerifier.Options is the options object for SSTable verification; onlySai (verify only Storage-Attached Indexes) and includeSai (also include SAI verification during full verification) are mutually exclusive modes, so the constructor rejects a combination of both with IllegalArgumentException.

Solutions

  1. Pass only one flag: use onlySai=true (includeSai=false) for SAI-only verification, or includeSai=true (onlySai=false) for full verification including SAI
  2. Add mutual-exclusion validation in the calling tool/UI before constructing Options
  3. If both semantics are wanted, run the verifier twice with each option set

Example fix

// before
new IVerifier.Options(..., true /*onlySai*/, true /*includeSai*/, ...);
// after
new IVerifier.Options(..., true /*onlySai*/, false /*includeSai*/, ...);
Defensive patterns

Strategy: validation

Validate before calling

if (onlySai && includeSai)
    throw new IllegalArgumentException("Choose either onlySai or includeSai, not both");

Type guard

boolean optionsValid = !(onlySai && includeSai);

Try / catch

try { opts = new IVerifier.Options(..., onlySai, includeSai, tokenLookup); }
catch (IllegalArgumentException e) {
    if (e.getMessage().contains("onlySai and includeSai both cannot be true"))
        // reset one flag and retry
}

Prevention

When it happens

Trigger: Programmatically constructing IVerifier.Options with onlySai=true and includeSai=true, e.g. custom verification tooling or tests that wire both flags.

Common situations: Tool/UI code accumulating boolean flags where a user selects both 'verify SAI only' and 'include SAI' checkboxes; scripted verification with over-broad flag sets.

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/397e6ae828d2a9aa. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/io/sstable/IVerifier.java:86

        /**
         * To include SAI verification along with data files
         */
        public final boolean includeSai;

        public final Function<String, ? extends Collection<Range<Token>>> tokenLookup;

        private Options(boolean invokeDiskFailurePolicy,
                        boolean extendedVerification,
                        boolean checkVersion,
                        boolean mutateRepairStatus,
                        boolean checkOwnsTokens,
                        boolean quick,
                        boolean onlySai,
                        boolean includeSai,
                        Function<String, ? extends Collection<Range<Token>>> tokenLookup)
        {
            if (onlySai && includeSai)
                throw new IllegalArgumentException("onlySai and includeSai both cannot be true at a time.");

            this.invokeDiskFailurePolicy = invokeDiskFailurePolicy;
            this.extendedVerification = extendedVerification;
            this.checkVersion = checkVersion;
            this.mutateRepairStatus = mutateRepairStatus;
            this.checkOwnsTokens = checkOwnsTokens;
            this.quick = quick;
            this.onlySai = onlySai;
            this.includeSai = includeSai;
            this.tokenLookup = tokenLookup;
        }

        @Override
        public String toString()
        {
            return "Options{" +
                   "invokeDiskFailurePolicy=" + invokeDiskFailurePolicy +
                   ", extendedVerification=" + extendedVerification +

View on GitHub (pinned to 88fd0f6a0e)