{"record":{"id":"397e6ae828d2a9aa","repo":"apache/cassandra","slug":"onlysai-and-includesai-both-cannot-be-true-at-a-ti","errorCode":null,"errorMessage":"onlySai and includeSai both cannot be true at a time.","messagePattern":"onlySai and includeSai both cannot be true at a time\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/sstable/IVerifier.java","lineNumber":86,"sourceCode":"        /**\n         * To include SAI verification along with data files\n         */\n        public final boolean includeSai;\n\n        public final Function<String, ? extends Collection<Range<Token>>> tokenLookup;\n\n        private Options(boolean invokeDiskFailurePolicy,\n                        boolean extendedVerification,\n                        boolean checkVersion,\n                        boolean mutateRepairStatus,\n                        boolean checkOwnsTokens,\n                        boolean quick,\n                        boolean onlySai,\n                        boolean includeSai,\n                        Function<String, ? extends Collection<Range<Token>>> tokenLookup)\n        {\n            if (onlySai && includeSai)\n                throw new IllegalArgumentException(\"onlySai and includeSai both cannot be true at a time.\");\n\n            this.invokeDiskFailurePolicy = invokeDiskFailurePolicy;\n            this.extendedVerification = extendedVerification;\n            this.checkVersion = checkVersion;\n            this.mutateRepairStatus = mutateRepairStatus;\n            this.checkOwnsTokens = checkOwnsTokens;\n            this.quick = quick;\n            this.onlySai = onlySai;\n            this.includeSai = includeSai;\n            this.tokenLookup = tokenLookup;\n        }\n\n        @Override\n        public String toString()\n        {\n            return \"Options{\" +\n                   \"invokeDiskFailurePolicy=\" + invokeDiskFailurePolicy +\n                   \", extendedVerification=\" + extendedVerification +","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/sstable/IVerifier.java#L68-L104","documentation":"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.","triggerScenarios":"Programmatically constructing IVerifier.Options with onlySai=true and includeSai=true, e.g. custom verification tooling or tests that wire both flags.","commonSituations":"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.","solutions":["Pass only one flag: use onlySai=true (includeSai=false) for SAI-only verification, or includeSai=true (onlySai=false) for full verification including SAI","Add mutual-exclusion validation in the calling tool/UI before constructing Options","If both semantics are wanted, run the verifier twice with each option set"],"exampleFix":"// before\nnew IVerifier.Options(..., true /*onlySai*/, true /*includeSai*/, ...);\n// after\nnew IVerifier.Options(..., true /*onlySai*/, false /*includeSai*/, ...);","handlingStrategy":"validation","validationCode":"if (onlySai && includeSai)\n    throw new IllegalArgumentException(\"Choose either onlySai or includeSai, not both\");","typeGuard":"boolean optionsValid = !(onlySai && includeSai);","tryCatchPattern":"try { opts = new IVerifier.Options(..., onlySai, includeSai, tokenLookup); }\ncatch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"onlySai and includeSai both cannot be true\"))\n        // reset one flag and retry\n}","preventionTips":["Model verification mode as an enum (FULL, SAI_ONLY, INCLUDE_SAI) instead of two booleans","Centralize Options construction in one helper that enforces exclusivity","Add UI/logic constraints preventing simultaneous flag selection"],"tags":["verification","sai","mutually-exclusive"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}