{"record":{"id":"fde395755b5c5ee2","repo":"apache/cassandra","slug":"s-is-not-a-valid-jmx-resource-name","errorCode":null,"errorMessage":"%s is not a valid JMX resource name","messagePattern":"(.+?) is not a valid JMX resource name","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/auth/JMXResource.java","lineNumber":79,"sourceCode":"    }\n\n    public static JMXResource mbean(String name)\n    {\n        return new JMXResource(name);\n    }\n\n    /**\n     * Parses a role resource name into a RoleResource instance.\n     *\n     * @param name Name of the data resource.\n     * @return RoleResource instance matching the name.\n     */\n    public static JMXResource fromName(String name)\n    {\n        String[] parts = StringUtils.split(name, '/');\n\n        if (!parts[0].equals(ROOT_NAME) || parts.length > 2)\n            throw new IllegalArgumentException(String.format(\"%s is not a valid JMX resource name\", name));\n\n        if (parts.length == 1)\n            return root();\n\n        return mbean(parts[1]);\n    }\n\n    @Override\n    public String getName()\n    {\n        if (level == Level.ROOT)\n            return ROOT_NAME;\n        else if (level == Level.MBEAN)\n            return String.format(\"%s/%s\", ROOT_NAME, name);\n        throw new AssertionError();\n    }\n\n    /**","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/auth/JMXResource.java#L61-L97","documentation":"JMXResource.fromName parses a JMX permission resource name ('jmx' or 'jmx/<mbean>'). It throws IllegalArgumentException when the first segment is not the literal root 'jmx' or when the name has more than 2 segments, since MBean resources are exactly one level deep.","triggerScenarios":"Calling JMXResource.fromName with 'jmx/a/b' (too deep), a wrong root like 'data/...' or 'jmxs/...', or an empty/malformed string.","commonSituations":"Deserializing permission entries where the resource kind prefix got mixed up; hand-writing MBean resource names with extra slash-delimited properties instead of the canonical ObjectName form; scripts iterating mixed resource lists and calling the wrong fromName.","solutions":["Use names of the form 'jmx' or 'jmx/<mbean-object-name>' with no additional '/'-separated levels","Encode the MBean ObjectName so it doesn't introduce extra '/' segments beyond the single resource level","Use JMXResource.mbean(name) or JMXResource.root() directly instead of parsing arbitrary strings"],"exampleFix":"// before\nJMXResource r = JMXResource.fromName(\"jmx/org/apache/type=Server\");\n// after\nJMXResource r = JMXResource.fromName(\"jmx/org.apache.cassandra.db:type=StorageService\");","handlingStrategy":"validation","validationCode":"boolean isValidJmxResourceName(String name) {\n    String[] parts = name.split(\"/\");\n    return parts.length >= 1 && parts.length <= 2 && \"jmx\".equals(parts[0]);\n}","typeGuard":null,"tryCatchPattern":"try { JMXResource r = JMXResource.fromName(name); } catch (IllegalArgumentException e) { log.error(\"bad jmx resource name: {}\", name); }","preventionTips":["Use JMXResource.root()/mbean(objectName) factories rather than string parsing","Ensure MBean ObjectNames don't inject extra '/'-separated levels","Route jmx resources only to JMXResource.fromName"],"tags":["cassandra","auth","jmx","resource-name"],"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"}