{"record":{"id":"6893e39037e2349a","repo":"apache/cassandra","slug":"unable-to-parse-targets-for-index-s-s","errorCode":null,"errorMessage":"Unable to parse targets for index %s (%s)","messagePattern":"Unable to parse targets for index (.+?) \\((.+?)\\)","errorType":"exception","errorClass":"org.apache.cassandra.exceptions.ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/index/TargetParser.java","lineNumber":53,"sourceCode":"{\n    private static final Pattern TARGET_REGEX = Pattern.compile(\"^(keys|entries|values|full)\\\\((.+)\\\\)$\");\n    private static final Pattern TWO_QUOTES = Pattern.compile(\"\\\"\\\"\");\n    private static final String QUOTE = \"\\\"\";\n\n    public static Optional<Pair<ColumnMetadata, IndexTarget.Type>> tryParse(TableMetadata metadata, IndexMetadata indexDef)\n    {\n        String target = indexDef.options.get(\"target\");\n        assert target != null : String.format(\"No target definition found for index %s\", indexDef.name);\n        return Optional.ofNullable(parse(metadata, target));\n    }\n\n    public static Pair<ColumnMetadata, IndexTarget.Type> parse(TableMetadata metadata, IndexMetadata indexDef)\n    {\n        String target = indexDef.options.get(\"target\");\n        assert target != null : String.format(\"No target definition found for index %s\", indexDef.name);\n        Pair<ColumnMetadata, IndexTarget.Type> result = parse(metadata, target);\n        if (result == null)\n            throw new ConfigurationException(String.format(\"Unable to parse targets for index %s (%s)\", indexDef.name, target));\n        return result;\n    }\n\n    public static Pair<ColumnMetadata, IndexTarget.Type> parse(TableMetadata metadata, String target)\n    {\n        // if the regex matches then the target is in the form \"keys(foo)\", \"entries(bar)\" etc\n        // if not, then it must be a simple column name and implictly its type is VALUES\n        Matcher matcher = TARGET_REGEX.matcher(target);\n        String columnName;\n        IndexTarget.Type targetType;\n        if (matcher.matches())\n        {\n            targetType = IndexTarget.Type.fromString(matcher.group(1));\n            columnName = matcher.group(2);\n        }\n        else\n        {\n            columnName = target;","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/index/TargetParser.java#L35-L71","documentation":"TargetParser.parse throws this ConfigurationException when an index definition's 'target' option cannot be matched to any valid target expression (column, keys(foo), entries(bar), etc.) for the table's schema. Cassandra throws it during CREATE INDEX / schema validation because a secondary index must know exactly which column(s) and index type it targets. A null parse result means the target string did not match the expected regexes or the column does not exist.","triggerScenarios":"CREATE INDEX with a 'target' option that is not a valid column name or target expression (e.g. misspelled column, wrong function wrapper like values() instead of keys(), target on a column missing from the table, malformed syntax such as unbalanced parentheses).","commonSituations":"Typo in the indexed column name; using full()/values()/keys()/entries() on unsupported column types (e.g. keys() on a non-map); restoring/rewriting schema YAML or snapshot schema tables with hand-edited target strings; CQL driver versions generating older target syntax.","solutions":["Fix the target string in CREATE INDEX to exactly match an existing column, e.g. CREATE INDEX ON my_table(my_column)","Use the correct target type for the column kind: keys(col) for map keys, values(col) for values, entries(col) for full map entries, full(col) for frozen collections","Verify the column exists in the table with DESCRIBE TABLE and that it is indexable (not already indexed, valid type)","If the error comes from schema tables/YAML, drop and recreate the index via CQL instead of hand-editing schema"],"exampleFix":"// before\nCREATE CUSTOM INDEX ON users (keys(tags)) USING 'StorageAttachedIndex';\n// tags is a set, not a map\n// after\nCREATE CUSTOM INDEX ON users (tags) USING 'StorageAttachedIndex';","handlingStrategy":"validation","validationCode":"ColumnMetadata col = metadata.getColumn(new ColumnIdentifier(targetColumn, true));\nif (col == null) throw new IllegalArgumentException(\"Unknown index target column: \" + targetColumn);","typeGuard":null,"tryCatchPattern":"try { Pair<ColumnMetadata, IndexTarget.Type> t = TargetParser.parse(metadata, indexDef); } catch (ConfigurationException e) { log.error(\"Bad index target: {}\", e.getMessage()); /* fix schema */ }","preventionTips":["Always generate CREATE INDEX targets from real column names (introspect schema)","Match wrapper functions to column types: keys/values/entries for maps only, full() for frozen only","Never hand-edit schema tables; recreate indexes via CQL"],"tags":["cassandra","index","configuration","schema-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}