Skip to content

[ISSUE #1443] Validate message body size before sending - #1444

Closed
tju-yxq wants to merge 1 commit into
apache:rocketmq-studiofrom
tju-yxq:fix/send-message-size-validation-1443
Closed

[ISSUE #1443] Validate message body size before sending#1444
tju-yxq wants to merge 1 commit into
apache:rocketmq-studiofrom
tju-yxq:fix/send-message-size-validation-1443

Conversation

@tju-yxq

@tju-yxq tju-yxq commented Aug 10, 2026

Copy link
Copy Markdown

What is the purpose of the change

Fixes #1443

sendMessage() did not validate body size before sending, causing HTTP 500 for messages exceeding the 4 MB broker limit.

Brief changelog

  • RocketMQAdminClientImpl.java: Added MAX_MESSAGE_SIZE constant (4 MB) and a pre-send size check that throws BusinessException(400) with a clear message.

Verifying this change

  1. Send a message with body > 4 MB.
  2. Before fix: HTTP 500 with confusing error.
  3. After fix: HTTP 400 with "Message body size X exceeds the maximum of 4194304 bytes".
  • Make sure there is a Github issue filed for the change.
  • Format the pull request title like [ISSUE #1443] ....
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@lizhimins
lizhimins force-pushed the rocketmq-studio branch 2 times, most recently from 269e228 to d58b463 Compare August 10, 2026 06:45
@lizhimins
lizhimins force-pushed the fix/send-message-size-validation-1443 branch from d5b1585 to d5d03ce Compare August 10, 2026 09:06

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looks good.


Automated review by github-manager-bot

The send message endpoint did not validate body size, causing HTTP 500
for messages exceeding the 4MB broker limit. This fix adds a pre-send
size check that returns HTTP 400 with a clear message.

Fixes apache#1443
@tju-yxq
tju-yxq force-pushed the fix/send-message-size-validation-1443 branch from d5d03ce to 9c705ed Compare August 10, 2026 10:34
lizhimins pushed a commit that referenced this pull request Aug 10, 2026
#1378, #1425, #1434, #1444)

* [ISSUE #1353] Handle OFFSET_ILLEGAL in message and DLQ pull scans

When PullResult returns OFFSET_ILLEGAL, the scan loop was breaking
out of the current queue, silently dropping all remaining messages
in that queue. The broker returns a corrected offset in
nextBeginOffset that should be retried.

This fix:
- Adds OFFSET_ILLEGAL handling to both queryByTopic() and
  collectDeadLetters() with continue instead of break
- Adds a max-retry guard (3 consecutive OFFSET_ILLEGAL per queue)
  to prevent infinite loops
- Resets the counter on successful FOUND pulls
- Preserves existing NO_NEW_MSG/NO_MATCHED_MSG break behavior

Fixes #1353

* [ISSUE #1424] Fix UTF-8 body display truncation at multi-byte boundary

When truncating message body for display, the truncation point could
fall in the middle of a multi-byte UTF-8 character, causing the decoder
to throw CharacterCodingException and fall through to BASE64 encoding
even for valid UTF-8 text. This fix walks back the truncation point to
the last complete UTF-8 character boundary before decoding.

Fixes #1424

* [ISSUE #1433] Validate message query time range start < end

The message query accepted inverted time ranges (start > end) without
validation, returning zero results with no explanation.

Fixes #1433

* [ISSUE #1443] Validate message body size before sending

The send message endpoint did not validate body size, causing HTTP 500
for messages exceeding the 4MB broker limit. This fix adds a pre-send
size check that returns HTTP 400 with a clear message.

Fixes #1443
@lizhimins

Copy link
Copy Markdown
Member

Consolidated into #1378 (same-author batch, merged via the author's own target PR). 已通过「合并相关 commit」并入同作者批次目标 PR #1378 合入。

@lizhimins lizhimins closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants