{"record":{"id":"bf208dfb87fb23e1","repo":"apache/rocketmq","slug":"the-specified-group-s-contains-illegal-character","errorCode":null,"errorMessage":"the specified group[%s] contains illegal characters, allowing only %s","messagePattern":"the specified group\\[(.+?)\\] contains illegal characters, allowing only (.+?)","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/Validators.java","lineNumber":60,"sourceCode":"     * Group name max length is 120, for it will be used to make up retry and DLQ topic,\n     * like pull retry: %RETRY%group_topic and pop retry: %RETRY%group_topic.\n     */\n    public static final int GROUP_MAX_LENGTH = 120;\n\n    /**\n     * Validate group\n     */\n    public static void checkGroup(String group) throws MQClientException {\n        if (UtilAll.isBlank(group)) {\n            throw new MQClientException(\"the specified group is blank\", null);\n        }\n\n        if (group.length() > GROUP_MAX_LENGTH) {\n            throw new MQClientException(String.format(\"the specified group[%s] is longer than group max length: %s.\", group, GROUP_MAX_LENGTH), null);\n        }\n\n        if (isTopicOrGroupIllegal(group)) {\n            throw new MQClientException(String.format(\n                    \"the specified group[%s] contains illegal characters, allowing only %s\", group,\n                    \"^[%|a-zA-Z0-9_-]+$\"), null);\n        }\n    }\n\n    public static void checkMessage(Message msg, DefaultMQProducer defaultMQProducer) throws MQClientException {\n        if (null == msg) {\n            throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, \"the message is null\");\n        }\n        // topic\n        Validators.checkTopic(msg.getTopic());\n        Validators.isNotAllowedSendTopic(msg.getTopic());\n\n        // body\n        if (null == msg.getBody()) {\n            throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, \"the message body is null\");\n        }\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/Validators.java#L42-L78","documentation":"Validators.checkGroup rejects group names containing characters outside [%|a-zA-Z0-9_-] (the regex check is isTopicOrGroupIllegal). Percent is tolerated, but spaces, dots, colons, slashes, CJK, and other symbols make the name illegal because it is used to compose retry/DLQ topic names.","triggerScenarios":"Calling setConsumerGroup/setProducerGroup (or the constructor) with names containing '.', ' ', ':', '/', '#', unicode, etc.; group names sourced from URLs or free-text fields.","commonSituations":"Using hostname or FQDN as the group; injecting a group with spaces from a properties file; names with dots (common when reusing Kafka consumer-group conventions).","solutions":["Restrict the group to letters, digits, underscore, hyphen (and % only if intentionally).","Replace dots/spaces with hyphens: 'order.service prod' -> 'order-service-prod'.","Add a config-time regex assertion: group.matches(\"^[%|a-zA-Z0-9_-]+$\") before client start."],"exampleFix":"// before\nconsumer.setConsumerGroup(\"order.service.prod\");\n\n// after\nconsumer.setConsumerGroup(\"order-service-prod\");","handlingStrategy":"validation","validationCode":"private static final Pattern LEGAL = Pattern.compile(\"^[%|a-zA-Z0-9_-]+$\");\n\nstatic boolean legalGroupName(String g) {\n    return g != null && LEGAL.matcher(g).matches();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize group names (replace '.', ' ', ':' with '-') at config load time.","Share one normalization utility across all services.","Reject Kafka-style dotted group names at CI config validation."],"tags":["rocketmq","client","group","validation","naming"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}