apache/cassandra · error · java.lang.IllegalArgumentException
%s is not a valid data resource name
Error message
%s is not a valid data resource name
What it means
DataResource.fromName parses a slash-delimited resource name (e.g. 'data', 'data/ks', 'data/ks/table') back into a DataResource. It throws IllegalArgumentException when the first segment is not 'data' or the name has more than 3 segments, i.e. the string is not a syntactically valid data resource name.
Source
Thrown at src/java/org/apache/cassandra/auth/DataResource.java:146
* @return DataResource instance representing the column family.
*/
public static DataResource table(String keyspace, String table)
{
return new DataResource(Level.TABLE, keyspace, table);
}
/**
* Parses a data resource name into a DataResource instance.
*
* @param name Name of the data resource.
* @return DataResource instance matching the name.
*/
public static DataResource fromName(String name)
{
String[] parts = StringUtils.split(name, '/');
if (!parts[0].equals(ROOT_NAME) || parts.length > 3)
throw new IllegalArgumentException(String.format("%s is not a valid data resource name", name));
if (parts.length == 1)
return root();
if (parts.length == 2)
return keyspace(parts[1]);
if ("*".equals(parts[2]))
return allTables(parts[1]);
return table(parts[1], parts[2]);
}
/**
* @return Printable name of the resource.
*/
public String getName()
{View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Print the offending name and verify it starts with 'data' and has 1-3 slash-separated segments
- Strip or correct extra path segments so the name is 'data', 'data/<keyspace>' or 'data/<keyspace>/<table>','or use the typed factories DataResource.root()/keyspace()/table() instead of parsing strings
- Confirm the string is actually a data resource and not a function/jmx/role resource; use the matching Resource class's fromName
Example fix
// before
DataResource r = DataResource.fromName("data/ks/tbl/col");
// after
DataResource r = DataResource.table("ks", "tbl"); Defensive patterns
Strategy: validation
Validate before calling
boolean isValidDataResourceName(String name) {
String[] parts = name.split("/");
return parts.length >= 1 && parts.length <= 3 && "data".equals(parts[0]);
} Try / catch
try { DataResource r = DataResource.fromName(name); } catch (IllegalArgumentException e) { log.error("bad data resource name: {}", name, e); } Prevention
- Always build resources via DataResource.root()/keyspace()/table() instead of hand-formatting strings
- Validate the 'data' prefix and segment count before parsing
- Never mix resource kinds: use DataResource.fromName only for data resources
When it happens
Trigger: Calling DataResource.fromName with a name like 'data/ks/table/col' (4 parts), a misspelled root such as 'dat/ks', an empty string, or a resource name captured/stored with a wrong prefix (e.g. a JMX or function resource name passed by mistake).
Common situations: Replaying stored GRANT/LIST PERMISSIONS output after a version change; hand-editing role/resource names in scripts; tools that serialize resources from other auth dimensions (functions, JMX, roles) and mislabel them as data resources.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- %s is not a valid function resource name
- %s is not a valid function resource name. It must end with "
- %s is not a valid JMX resource name
- REVOKE operation is not supported by AllowAllAuthorizer
- In this context function name must be explictly qualified by
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/3b6b865c02c3b126.
Report an issue: GitHub.