{"record":{"id":"0a4655fae1f36fb7","repo":"apache/rocketmq","slug":"16","errorCode":"16","errorMessage":"topicPermission value: %s is invalid.","messagePattern":"topicPermission value: (.+?) is invalid\\.","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/Validators.java","lineNumber":128,"sourceCode":"    }\n\n    public static void isSystemTopic(String topic) throws MQClientException {\n        if (TopicValidator.isSystemTopic(topic)) {\n            throw new MQClientException(\n                    String.format(\"The topic[%s] is conflict with system topic.\", topic), null);\n        }\n    }\n\n    public static void isNotAllowedSendTopic(String topic) throws MQClientException {\n        if (TopicValidator.isNotAllowedSendTopic(topic)) {\n            throw new MQClientException(\n                    String.format(\"Sending message to topic[%s] is forbidden.\", topic), null);\n        }\n    }\n\n    public static void checkTopicConfig(final TopicConfig topicConfig) throws MQClientException {\n        if (!PermName.isValid(topicConfig.getPerm())) {\n            throw new MQClientException(ResponseCode.NO_PERMISSION,\n                String.format(\"topicPermission value: %s is invalid.\", topicConfig.getPerm()));\n        }\n    }\n\n    public static void checkBrokerConfig(final Properties brokerConfig) throws MQClientException {\n        String brokerPermission = brokerConfig.getProperty(\"brokerPermission\");\n        if (brokerPermission != null && !PermName.isValid(brokerPermission)) {\n            throw new MQClientException(ResponseCode.NO_PERMISSION,\n                    String.format(\"brokerPermission value: %s is invalid.\", brokerPermission));\n        }\n    }\n}\n","sourceCodeStart":110,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/Validators.java#L110-L141","documentation":"Thrown by Validators.checkTopicConfig when the TopicConfig's permission value fails PermName.isValid(). RocketMQ encodes topic permissions as a bitmask (2=READ, 4=WRITE, 6=READ|WRITE); any value outside the accepted set is rejected before the config is sent to the broker. The exception carries response code 16 (NO_PERMISSION). It exists to stop clients from pushing a malformed permission string to the server, which would silently produce an unusable topic.","triggerScenarios":"Calling an admin API that validates a TopicConfig (e.g. topic creation/update utilities that call Validators.checkTopicConfig) with topicConfig.setPerm() set to an invalid number such as 0, 5, 8, or a non-numeric string.","commonSituations":"Scripts or tools that build TopicConfig programmatically and pass an arbitrary int; porting code from another client where permissions were a string like 'rw'; typos when copying example configs.","solutions":["Set the perm to a valid bitmask: 6 (read+write), 4 (write-only), or 2 (read-only)","If the perm comes from user input or a config file, parse and validate it with org.apache.rocketmq.common.protocol.body PermName.isValid(...) before constructing the TopicConfig","Check for accidental double-setting of perm (e.g. setPerm(perm | 8) introducing an invalid bit)"],"exampleFix":"// before\ntopicConfig.setPerm(5); // invalid bitmask\n\n// after\ntopicConfig.setPerm(PermName.PERM_READ | PermName.PERM_WRITE); // 6","handlingStrategy":"validation","validationCode":"import org.apache.rocketmq.common.protocol.body.PermName;\n\nboolean ok = PermName.isValid(String.valueOf(topicConfig.getPerm()));\nif (!ok) {\n    topicConfig.setPerm(PermName.PERM_READ | PermName.PERM_WRITE);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Validators.checkTopicConfig(topicConfig);\n} catch (MQClientException e) {\n    if (e.getResponseCode() == ResponseCode.NO_PERMISSION) {\n        // fix perm value, log and surface config error to operator\n    }\n    throw e;\n}","preventionTips":["Never hardcode perm numbers in scripts; use PermName.PERM_READ/PERM_WRITE constants","Validate any perm coming from external config with PermName.isValid before building TopicConfig","Unit-test config builders against the valid set {2, 4, 6}"],"tags":["config","validation","permissions","topic"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}