tju-yxq opened a new issue, #1443: URL: https://github.com/apache/rocketmq-dashboard/issues/1443
## Bug Report ### Before Creating the Bug Report - [x] I found a bug, not just asking a question, which should be created in [GitHub Discussions](https://github.com/apache/rocketmq/discussions). - [x] I have searched the [GitHub Issues](https://github.com/apache/rocketmq/issues) and [GitHub Discussions](https://github.com/apache/rocketmq/discussions) of this repository and believe that this is not a duplicate. - [x] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ. ### Runtime platform environment OS: Ubuntu 20.04 / Any OS running RocketMQ Studio ### RocketMQ version branch: rocketmq-studio version: 5.3.2+ Git commit id: f727341 ### JDK Version OpenJDK 21 ### Describe the Bug `RocketMQAdminClientImpl.sendMessage()` does not validate the message body size before sending. RocketMQ's default `maxMessageSize` is 4 MB (4,194,304 bytes). If a user sends a message body larger than this limit through the Studio UI, the producer throws `MQClientException` with a confusing message like "message body size exceeds maxMessageSize". The Studio then returns HTTP 500 with "Failed to send message: ..." instead of a clear 400 error. Additionally, the `sendMsgTimeout` is hardcoded to 5000ms and is not configurable. For large messages or slow networks, 5 seconds may be too short. ### Steps to Reproduce 1. Open RocketMQ Studio message send page. 2. Paste a message body larger than 4 MB. 3. Click Send. 4. Observe: HTTP 500 with "Failed to send message: message body size exceeds maxMessageSize". ### What Did You Expected to See? HTTP 400 with "Message body size exceeds the maximum of 4 MB" before the message is sent to the producer. ### What Did You See Instead? HTTP 500 with a confusing internal error message. ### Additional Context **Affected file**: `server/src/main/java/org/apache/rocketmq/studio/provider/apache/RocketMQAdminClientImpl.java`, method `sendMessage()` at approximately line 320. **Fix**: Add a size check before creating the producer: ```java private static final int MAX_MESSAGE_SIZE = 4 * 1024 * 1024; // 4 MB public SendMessageVO sendMessage(SendMessageDTO request) { // ... String body = request.getBody() != null ? request.getBody() : ""; byte[] bodyBytes = body.getBytes(StandardCharsets.UTF_8); if (bodyBytes.length > MAX_MESSAGE_SIZE) { throw new BusinessException(400, "Message body size " + bodyBytes.length + " exceeds the maximum of " + MAX_MESSAGE_SIZE + " bytes"); } // ... } ``` This is a 6-line fix. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
