{"record":{"id":"53510633fd8ddfda","repo":"apache/rocketmq","slug":"13","errorCode":"13","errorMessage":"the message is null","messagePattern":"the message is null","errorType":"validation","errorClass":"MQClientException","httpStatus":null,"severity":"error","filePath":"client/src/main/java/org/apache/rocketmq/client/Validators.java","lineNumber":68,"sourceCode":"    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\n        if (0 == msg.getBody().length) {\n            throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL, \"the message body length is zero\");\n        }\n\n        if (msg.getBody().length > defaultMQProducer.getMaxMessageSize()) {\n            throw new MQClientException(ResponseCode.MESSAGE_ILLEGAL,\n                \"the message body size over max value, MAX: \" + defaultMQProducer.getMaxMessageSize());\n        }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/apache/rocketmq/blob/293f5885719fc4aa3619446a1900f58ccfcfdd29/client/src/main/java/org/apache/rocketmq/client/Validators.java#L50-L86","documentation":"Validators.checkMessage (called from producer.send paths) rejects a null Message object with MQClientException code 13 (MESSAGE_ILLEGAL). This is a pure client-side null check before topic/body validation runs.","triggerScenarios":"Calling producer.send(null) or producer.send(null, timeout) — typically when the calling code builds a message from a map/optional and the lookup returned null.","commonSituations":"Optional.map(...).orElse(null) feeding send(); a null returned from a builder when input is invalid; refactoring that removed a null branch.","solutions":["Guard the call site: only send when the constructed Message is non-null, or throw a domain-specific exception instead.","Fix the upstream builder so it never returns null (return Optional<Message> and chain).","Enable strict null checks / @NonNull annotations on the send wrapper."],"exampleFix":"// before\nMessage m = buildMessage(event); // may return null\nproducer.send(m);\n\n// after\nMessage m = buildMessage(event);\nif (m != null) {\n    producer.send(m);\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean isSendable(Message msg) {\n    return msg != null;\n}","tryCatchPattern":"try {\n    producer.send(msg);\n} catch (MQClientException e) {\n    if (e.getResponseCode() == ResponseCode.MESSAGE_ILLEGAL && \"the message is null\".equals(e.getMessage())) {\n        // caller-side bug: fix message construction, do not retry\n    }\n}","preventionTips":["Make message builders return Optional<Message>, never null.","Annotate send wrappers with @NonNull parameters."],"tags":["rocketmq","producer","validation","null-check"],"backgroundTag":null,"analyzedSha":"293f5885719fc4aa3619446a1900f58ccfcfdd29","analyzedAt":"2026-08-14T11:50:13.822Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}