{"record":{"id":"891225241605e8c8","repo":"apache/cassandra","slug":"incorrect-index-mode-s","errorCode":null,"errorMessage":"Incorrect index mode: %s","messagePattern":"Incorrect index mode: (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/sasi/conf/IndexMode.java","lineNumber":141,"sourceCode":"        return getMode(column, config.isPresent() ? config.get().options : null);\n    }\n\n    public static IndexMode getMode(ColumnMetadata column, Map<String, String> indexOptions) throws ConfigurationException\n    {\n        if (indexOptions == null || indexOptions.isEmpty())\n            return IndexMode.NOT_INDEXED;\n\n        Mode mode;\n\n        try\n        {\n            mode = indexOptions.get(INDEX_MODE_OPTION) == null\n                            ? Mode.PREFIX\n                            : Mode.mode(indexOptions.get(INDEX_MODE_OPTION));\n        }\n        catch (IllegalArgumentException e)\n        {\n            throw new ConfigurationException(\"Incorrect index mode: \" + indexOptions.get(INDEX_MODE_OPTION));\n        }\n\n        boolean isAnalyzed = false;\n        Class<? extends AbstractAnalyzer> analyzerClass = null;\n        if (indexOptions.get(INDEX_ANALYZER_CLASS_OPTION) != null)\n        {\n            try\n            {\n                analyzerClass = FBUtilities.classForNameWithoutInitialization(indexOptions.get(INDEX_ANALYZER_CLASS_OPTION),\n                                                                              \"analyzer\",\n                                                                              AbstractAnalyzer.class);\n                isAnalyzed = indexOptions.get(INDEX_ANALYZED_OPTION) == null\n                             ? true : Boolean.parseBoolean(indexOptions.get(INDEX_ANALYZED_OPTION));\n            }\n            catch (ConfigurationException e)\n            {\n                if (!(e.getCause() instanceof ClassNotFoundException))\n                    throw e;","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/sasi/conf/IndexMode.java#L123-L159","documentation":"IndexMode.getMode parses the 'mode' index option via Mode.mode(), which throws IllegalArgumentException for unknown mode strings. getMode catches it and rethrows a clearer ConfigurationException: 'Incorrect index mode: <value>'.","triggerScenarios":"CREATE CUSTOM INDEX ... WITH OPTIONS = {'mode': 'FULLTEXT'} or any string other than PREFIX, CONTAINS, SPARSE (case-sensitive); any typo in the mode option value.","commonSituations":"Typos like 'contains' vs 'CONTAINS', or copying mode names from other search engines (e.g. Elasticsearch) into SASI options.","solutions":["Use one of the valid modes: PREFIX, CONTAINS, or SPARSE (uppercase)","Remove the 'mode' option to accept the PREFIX default","Validate the mode string against Mode.mode() before creating the index"],"exampleFix":"// before\nOPTIONS = {'mode': 'FULLTEXT'}\n// after\nOPTIONS = {'mode': 'CONTAINS'}","handlingStrategy":"validation","validationCode":"Set<String> valid = Set.of(\"PREFIX\", \"CONTAINS\", \"SPARSE\");\nString mode = options.get(\"mode\");\nif (mode != null && !valid.contains(mode)) throw new ConfigurationException(\"Invalid SASI mode: \" + mode + \"; expected one of \" + valid);","typeGuard":null,"tryCatchPattern":"try { session.execute(createIndexCql); } catch (ConfigurationException e) { if (e.getMessage().startsWith(\"Incorrect index mode\")) { options.put(\"mode\", \"PREFIX\"); session.execute(rebuildCql(options)); } else throw e; }","preventionTips":["Use exact uppercase mode names: PREFIX, CONTAINS, SPARSE","Centralize mode constants instead of raw strings in CQL generation"],"tags":["sasi","index-options","invalid-value","configuration"],"backgroundTag":"invalid-enum-value","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"}