{"record":{"id":"fa362c67ff512905","repo":"apache/cassandra","slug":"options-to-normalize-terms-cannot-be-both-uppercas-fa362c","errorCode":null,"errorMessage":"Options to normalize terms cannot be both uppercase and lowercase at the same time","messagePattern":"Options to normalize terms cannot be both uppercase and lowercase at the same time","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sasi/analyzer/StandardTokenizerOptions.java","lineNumber":205,"sourceCode":"            return this;\n        }\n\n        /**\n         * Set the max allowed token length.  Any token longer\n         * than this is skipped.\n         */\n        public OptionsBuilder maxTokenLength(int maxTokenLength)\n        {\n            if (maxTokenLength < 1)\n                throw new IllegalArgumentException(\"maxTokenLength must be greater than zero\");\n            this.maxTokenLength = maxTokenLength;\n            return this;\n        }\n\n        public StandardTokenizerOptions build()\n        {\n            if(allTermsToLowerCase && allTermsToUpperCase)\n                throw new IllegalArgumentException(\"Options to normalize terms cannot be \" +\n                        \"both uppercase and lowercase at the same time\");\n\n            StandardTokenizerOptions options = new StandardTokenizerOptions();\n            options.setIgnoreStopTerms(ignoreStopTerms);\n            options.setStemTerms(stemTerms);\n            options.setLocale(locale);\n            options.setCaseSensitive(caseSensitive);\n            options.setAllTermsToLowerCase(allTermsToLowerCase);\n            options.setAllTermsToUpperCase(allTermsToUpperCase);\n            options.setMinTokenLength(minTokenLength);\n            options.setMaxTokenLength(maxTokenLength);\n            return options;\n        }\n    }\n\n    public static StandardTokenizerOptions buildFromMap(Map<String, String> optionsMap)\n    {\n        OptionsBuilder optionsBuilder = new OptionsBuilder();","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sasi/analyzer/StandardTokenizerOptions.java#L187-L223","documentation":"StandardTokenizerOptions.build() rejects a configuration where allTermsToLowerCase and allTermsToUpperCase are both true, since terms cannot be normalized to both lower and upper case simultaneously. Throws IllegalArgumentException before constructing the options.","triggerScenarios":"new StandardTokenizerOptions.Builder().setAllTermsToLowerCase(true).setAllTermsToUpperCase(true).build(), or building from option maps with both 'normalize_lowercase' and 'normalize_uppercase' set.","commonSituations":"Merged/overlapping option maps from tooling; users treating the two flags as independent toggles.","solutions":["Set only one of lower/upper case normalization to true","Leave both false to preserve original token casing","Add pre-build validation of the flags"],"exampleFix":"// before\nbuilder.setAllTermsToLowerCase(true).setAllTermsToUpperCase(true).build();\n// after\nbuilder.setAllTermsToLowerCase(true).setAllTermsToUpperCase(false).build();","handlingStrategy":"validation","validationCode":"if (allTermsToLowerCase && allTermsToUpperCase) throw new IllegalArgumentException(\"Only one of lowercase/uppercase term normalization may be enabled\");","typeGuard":null,"tryCatchPattern":"try { StandardTokenizerOptions opts = builder.build(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"both uppercase and lowercase\")) { builder.setAllTermsToUpperCase(false); StandardTokenizerOptions opts = builder.build(); } }","preventionTips":["Model normalization as a single enum in config, not two booleans","Validate merged option maps before building tokenizer options"],"tags":["sasi","tokenizer","conflicting-options","options-builder"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}