{"record":{"id":"0f77e8abdea59a1d","repo":"apache/cassandra","slug":"illegal-index-name-name","errorCode":null,"errorMessage":"Illegal index name ${name}","messagePattern":"Illegal index name (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/IndexMetadata.java","lineNumber":137,"sourceCode":"                                                              .collect(Collectors.joining(\", \")));\n        return new IndexMetadata(name, newOptions, kind);\n    }\n\n    public static String generateDefaultIndexName(String table, ColumnIdentifier column)\n    {\n        return PATTERN_NON_WORD_CHAR.matcher(table + '_' + column.toString() + \"_idx\").replaceAll(\"\");\n    }\n\n    public static String generateDefaultIndexName(String table)\n    {\n        return PATTERN_NON_WORD_CHAR.matcher(table + \"_idx\").replaceAll(\"\");\n    }\n\n    public void validate(TableMetadata table)\n    {\n        // TODO: address validating the length by CASSANDRA-20445\n        if (!isValidCharsName(name))\n            throw new ConfigurationException(\"Illegal index name \" + name);\n\n        if (kind == null)\n            throw new ConfigurationException(\"Index kind is null for index \" + name);\n\n        if (kind == Kind.CUSTOM)\n        {\n            if (options == null || !options.containsKey(IndexTarget.CUSTOM_INDEX_OPTION_NAME))\n                throw new ConfigurationException(String.format(\"Required option missing for index %s : %s\",\n                                                               name, IndexTarget.CUSTOM_INDEX_OPTION_NAME));\n\n            // Get the fully qualified class name:\n            String className = getIndexClassName();\n\n            Class<? extends Index> indexerClass = FBUtilities.classForNameWithoutInitialization(className, \"custom indexer\", Index.class);\n            validateCustomIndexOptions(table, indexerClass, options);\n        }\n    }\n","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/IndexMetadata.java#L119-L155","documentation":"Generic guard in IndexMetadata.validate: the index name violates the required identifier pattern (alphanumeric/underscore, must not be empty) — message 'Illegal index name ${name}'. Thrown as InvalidRequestException during CREATE/DROP INDEX schema validation; the at-fault input is the user-supplied index name string.","triggerScenarios":"Creating an index whose name contains characters rejected by isValidCharsName (e.g. spaces, dots, non-ASCII symbols), then validate() is called during schema construction/creation.","commonSituations":"Programmatic schema generation deriving index names from column expressions like 'idx(col desc)' which contain parentheses or spaces; copying a display name straight into the index name.","solutions":["Rename the index using only alphanumeric characters and underscores","Quote the identifier in CQL if needed, but keep the characters valid","Sanitize generated names: replace invalid chars with '_' before creating IndexMetadata"],"exampleFix":"// before\nIndexMetadata.raw(\"idx(col desc)\", ...)\n// after\nIndexMetadata.raw(\"idx_col_desc\", ...)","handlingStrategy":"validation","validationCode":"if (!name.matches(\"[a-zA-Z0-9_]+\")) throw new IllegalArgumentException(\"illegal index name: \" + name);","typeGuard":null,"tryCatchPattern":"try { index.validate(table); } catch (ConfigurationException e) { log.error(\"invalid index name \" + index.name, e); }","preventionTips":["Sanitize generated index names (replace invalid chars with '_')","Never embed column expressions or descriptions in index names","Follow the same character rules as CQL identifiers"],"tags":["index","naming","validation"],"backgroundTag":"invalid-identifier-format","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"}