Skip to content

[ISSUE #10791] Reject empty proxy heartbeat bodies - #10792

Open
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-heartbeat-empty-body
Open

[ISSUE #10791] Reject empty proxy heartbeat bodies#10792
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-heartbeat-empty-body

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • reject empty decoded remoting heartbeat bodies with INVALID_PARAMETER instead of falling into NPE handling
  • reject heartbeat payloads whose producer or consumer data sets are explicitly null
  • add ClientManagerActivityTest coverage to ensure malformed heartbeats do not register clients

Tests

  • mvn -pl proxy -Dtest=ClientManagerActivityTest test

Closes #10791

Copilot AI review requested due to automatic review settings August 3, 2026 13:34

Copilot 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.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

This PR hardens proxy remoting heartbeat handling by explicitly rejecting malformed/empty heartbeat payloads with INVALID_PARAMETER, preventing client registration side effects.

Changes:

  • Add validation in ClientManagerActivity#heartBeat for empty/undecodable bodies and null producer/consumer datasets.
  • Add ClientManagerActivityTest coverage to ensure malformed heartbeats do not register producers/consumers or touch channel management.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/ClientManagerActivity.java Adds early validation and returns INVALID_PARAMETER for empty heartbeat / null datasets.
proxy/src/test/java/org/apache/rocketmq/proxy/remoting/activity/ClientManagerActivityTest.java Adds tests asserting malformed heartbeats are rejected and do not register clients.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +81 to +87
if (heartbeatData == null) {
return RemotingCommand.buildErrorResponse(ResponseCode.INVALID_PARAMETER, "heartbeat data is empty");
}
if (heartbeatData.getProducerDataSet() == null || heartbeatData.getConsumerDataSet() == null) {
return RemotingCommand.buildErrorResponse(ResponseCode.INVALID_PARAMETER,
"heartbeat producerDataSet and consumerDataSet are required");
}
Comment on lines +66 to +77
@Test
public void testHeartbeatShouldRejectNullDataSets() {
RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.HEART_BEAT, null);
request.setBody("{\"clientID\":\"client-a\",\"producerDataSet\":null,\"consumerDataSet\":[]}"
.getBytes(StandardCharsets.UTF_8));

RemotingCommand response = clientManagerActivity.heartBeat(null, request, ProxyContext.create());

assertThat(response.getCode()).isEqualTo(ResponseCode.INVALID_PARAMETER);
assertThat(response.getRemark()).isEqualTo("heartbeat producerDataSet and consumerDataSet are required");
verifyNoClientRegistration();
}
@codecov-commenter

codecov-commenter commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 48.27%. Comparing base (eddb235) to head (b449c1b).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...proxy/remoting/activity/ClientManagerActivity.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10792      +/-   ##
=============================================
- Coverage      48.34%   48.27%   -0.08%     
+ Complexity     13527    13499      -28     
=============================================
  Files           1380     1380              
  Lines         101104   101142      +38     
  Branches       13107    13122      +15     
=============================================
- Hits           48882    48827      -55     
- Misses         46267    46328      +61     
- Partials        5955     5987      +32     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

[Bug] Proxy remoting heartbeat should reject empty request bodies

3 participants