{"record":{"id":"3b6b865c02c3b126","repo":"apache/cassandra","slug":"s-is-not-a-valid-data-resource-name","errorCode":null,"errorMessage":"%s is not a valid data resource name","messagePattern":"(.+?) is not a valid data resource name","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/auth/DataResource.java","lineNumber":146,"sourceCode":"     * @return DataResource instance representing the column family.\n     */\n    public static DataResource table(String keyspace, String table)\n    {\n        return new DataResource(Level.TABLE, keyspace, table);\n    }\n\n    /**\n     * Parses a data resource name into a DataResource instance.\n     *\n     * @param name Name of the data resource.\n     * @return DataResource instance matching the name.\n     */\n    public static DataResource fromName(String name)\n    {\n        String[] parts = StringUtils.split(name, '/');\n\n        if (!parts[0].equals(ROOT_NAME) || parts.length > 3)\n            throw new IllegalArgumentException(String.format(\"%s is not a valid data resource name\", name));\n\n        if (parts.length == 1)\n            return root();\n\n        if (parts.length == 2)\n            return keyspace(parts[1]);\n\n        if (\"*\".equals(parts[2]))\n            return allTables(parts[1]);\n\n        return table(parts[1], parts[2]);\n    }\n\n    /**\n     * @return Printable name of the resource.\n     */\n    public String getName()\n    {","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/auth/DataResource.java#L128-L164","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nDataResource r = DataResource.fromName(\"data/ks/tbl/col\");\n// after\nDataResource r = DataResource.table(\"ks\", \"tbl\");","handlingStrategy":"validation","validationCode":"boolean isValidDataResourceName(String name) {\n    String[] parts = name.split(\"/\");\n    return parts.length >= 1 && parts.length <= 3 && \"data\".equals(parts[0]);\n}","typeGuard":null,"tryCatchPattern":"try { DataResource r = DataResource.fromName(name); } catch (IllegalArgumentException e) { log.error(\"bad data resource name: {}\", name, e); }","preventionTips":["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"],"tags":["cassandra","auth","resource-name","validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}