{"record":{"id":"f59616e4fe2933d4","repo":"apache/rocketmq","slug":"the-specified-group-s-is-longer-than-group-max-l","errorCode":null,"errorMessage":"the specified group[%s] is longer than group max length: %s.","messagePattern":"the specified group\\[(.+?)\\] is longer than group max length: (.+?)\\.","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/Validators.java","lineNumber":56,"sourceCode":"public class Validators {\n    public static final int CHARACTER_MAX_LENGTH = 255;\n    public static final int TOPIC_MAX_LENGTH = 127;\n    /*\n     * 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","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/Validators.java#L38-L74","documentation":"Validators.checkGroup rejects group names longer than 120 characters. The 120 limit exists because the group is embedded into generated topic names (%RETRY%group / %DLQ%group), which must stay within the broker's topic length ceiling (127).","triggerScenarios":"Passing a group string built by concatenating app + env + instance + UUID that exceeds 120 chars; programmatically generated group names in multi-tenant systems.","commonSituations":"Auto-generated group names that append suffixes (env, region, version) until they cross 120; migrating from another MQ where longer consumer names were allowed.","solutions":["Shorten the group to <=120 characters (use an abbreviation scheme for env/region suffixes).","Add a unit test asserting generated group names stay under Validators.GROUP_MAX_LENGTH.","Hash or truncate deterministic long identifiers when composing group names."],"exampleFix":"// before\nString group = appName + '-' + env + '-' + UUID.randomUUID().toString(); // often > 120\n\n// after\nString group = appName + '-' + env + '-' + Integer.toHexString(hash).substring(0, 8);","handlingStrategy":"validation","validationCode":"static void assertGroupLength(String group) {\n    if (group != null && group.length() > 120) {\n        throw new IllegalArgumentException(\"group exceeds 120 chars: \" + group.length());\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a unit test bounding generated group names to 120 chars.","Avoid embedding UUIDs in group names.","Remember group length is capped because of %RETRY%/%DLQ% topic-name composition."],"tags":["rocketmq","client","group","validation","length-limit"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}