apache/cassandra · error · IllegalArgumentException

Name is not valid for any resource type

Error message

Name %s is not valid for any resource type

What it means

Resources.fromName() maps a resource name string to the correct IResource (DataResource, FunctionResource, JMXResource, etc.) by prefix-matching against each type's root name. If no known root prefix matches, the name is not a valid resource of any type and IllegalArgumentException is thrown.

Solutions

  1. Use the documented resource syntax: data/<keyspace>[/<table>], <keyspace>.<function>[args], jmx/<mbean>, all-keyspaces, roles, etc.
  2. Quote the resource name properly in CQL, e.g. GRANT SELECT ON KEYSPACE my_ks TO role_name
  3. Validate the prefix with the target type's root (e.g. DataResource.root().getName()) before calling fromName

Example fix

// before
GRANT SELECT ON 'keyspace1' TO reader;   -- invalid name
// after
GRANT SELECT ON KEYSPACE keyspace1 TO reader;
Defensive patterns

Strategy: try-catch

Validate before calling

boolean ok = name.startsWith("data/") || name.startsWith("functions/") || name.startsWith("jmx/") || name.equals("<all-keyspaces>") || name.matches("[a-zA-Z0-9_]+\\.[a-zA-Z0-9_]+(\\[.*\\])?");

Type guard

boolean isWellFormedResourceName(String name) { return DATA_ROOTS.stream().anyMatch(name::startsWith); }

Try / catch

try { grant(resource, role); } catch (IllegalArgumentException e) { if (e.getMessage().contains("not valid for any resource type")) printValidResourceFormats(); }

Prevention

When it happens

Trigger: GRANT/REVOKE/LIST PERMISSIONS with a misspelled or malformed resource name, e.g. GRANT SELECT ON 'keyspace1' (missing data/ or <keyspace> prefix form), or a name for a resource type that doesn't exist.

Common situations: Hand-written CQL permission grants with wrong quoting/prefixes; automation generating resource names that don't match the documented formats like data/ks, functions/ks, jmx; copy-pasted names from different Cassandra versions.

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.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/c97852a1a4e0b511. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/auth/Resources.java:78

    /**
     * Creates an IResource instance from its external name.
     * Resource implementation class is inferred by matching against the known IResource
     * impls' root level resources.
     * @param name external name to create IResource from
     * @return an IResource instance created from the name
     */
    public static IResource fromName(String name)
    {
        if (name.startsWith(RoleResource.root().getName()))
            return RoleResource.fromName(name);
        else if (name.startsWith(DataResource.root().getName()))
            return DataResource.fromName(name);
        else if (name.startsWith(FunctionResource.root().getName()))
            return FunctionResource.fromName(name);
        else if (name.startsWith(JMXResource.root().getName()))
            return JMXResource.fromName(name);
        else
            throw new IllegalArgumentException(String.format("Name %s is not valid for any resource type", name));
    }
}

View on GitHub (pinned to 88fd0f6a0e)