apache/cassandra · error · org.apache.cassandra.exceptions.ConfigurationException
Unable to parse targets for index %s (%s)
Error message
Unable to parse targets for index %s (%s)
What it means
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.
Source
Thrown at src/java/org/apache/cassandra/index/TargetParser.java:53
{
private static final Pattern TARGET_REGEX = Pattern.compile("^(keys|entries|values|full)\\((.+)\\)$");
private static final Pattern TWO_QUOTES = Pattern.compile("\"\"");
private static final String QUOTE = "\"";
public static Optional<Pair<ColumnMetadata, IndexTarget.Type>> tryParse(TableMetadata metadata, IndexMetadata indexDef)
{
String target = indexDef.options.get("target");
assert target != null : String.format("No target definition found for index %s", indexDef.name);
return Optional.ofNullable(parse(metadata, target));
}
public static Pair<ColumnMetadata, IndexTarget.Type> parse(TableMetadata metadata, IndexMetadata indexDef)
{
String target = indexDef.options.get("target");
assert target != null : String.format("No target definition found for index %s", indexDef.name);
Pair<ColumnMetadata, IndexTarget.Type> result = parse(metadata, target);
if (result == null)
throw new ConfigurationException(String.format("Unable to parse targets for index %s (%s)", indexDef.name, target));
return result;
}
public static Pair<ColumnMetadata, IndexTarget.Type> parse(TableMetadata metadata, String target)
{
// if the regex matches then the target is in the form "keys(foo)", "entries(bar)" etc
// if not, then it must be a simple column name and implictly its type is VALUES
Matcher matcher = TARGET_REGEX.matcher(target);
String columnName;
IndexTarget.Type targetType;
if (matcher.matches())
{
targetType = IndexTarget.Type.fromString(matcher.group(1));
columnName = matcher.group(2);
}
else
{
columnName = target;View on GitHub (pinned to 88fd0f6a0e)
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
Example fix
// before CREATE CUSTOM INDEX ON users (keys(tags)) USING 'StorageAttachedIndex'; // tags is a set, not a map // after CREATE CUSTOM INDEX ON users (tags) USING 'StorageAttachedIndex';
Defensive patterns
Strategy: validation
Validate before calling
ColumnMetadata col = metadata.getColumn(new ColumnIdentifier(targetColumn, true));
if (col == null) throw new IllegalArgumentException("Unknown index target column: " + targetColumn); Try / catch
try { Pair<ColumnMetadata, IndexTarget.Type> t = TargetParser.parse(metadata, indexDef); } catch (ConfigurationException e) { log.error("Bad index target: {}", e.getMessage()); /* fix schema */ } Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Properties specified %s are not understood by %s
- Must specify index implementation via USING
- Load CIDR groups cache operation not supported by %s
- Unsupported parameter '%s' for %s, supported parameters are
- JAAS login configuration missing for JMX authenticator setup
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/6893e39037e2349a.
Report an issue: GitHub.