Skip to content

[ISSUE #10782] Set error code for empty lock batch MQ - #10783

Open
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-lock-empty-mq-code
Open

[ISSUE #10782] Set error code for empty lock batch MQ#10783
Aias00 wants to merge 1 commit into
apache:developfrom
Aias00:fix/proxy-lock-empty-mq-code

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What is changed

  • Set an explicit failure response code when Proxy receives LOCK_BATCH_MQ or UNLOCK_BATCH_MQ with an empty MessageQueue set.
  • Keep the existing response body and remark so clients still get the diagnostic message.
  • Add remoting activity coverage for both empty lock and unlock paths and verify Proxy does not forward invalid requests to the broker.

Fixes #10782

Verification

  • mvn -pl proxy -Dtest=ConsumerManagerActivityTest test

Copilot AI review requested due to automatic review settings August 3, 2026 07:37

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 ensures Proxy returns an explicit failure response code when handling LOCK_BATCH_MQ / UNLOCK_BATCH_MQ requests that contain an empty MessageQueue set, and adds tests to verify the rejection behavior and that invalid requests are not forwarded to the broker.

Changes:

  • Set ResponseCode.SYSTEM_ERROR for empty lock/unlock MQ batch requests while preserving the existing remark/body.
  • Add remoting activity tests covering empty lock and unlock paths.
  • Verify MessagingProcessor.request(...) is not invoked for invalid requests.

Reviewed changes

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

File Description
proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/ConsumerManagerActivity.java Sets an explicit response code for empty MQ-set lock/unlock requests.
proxy/src/test/java/org/apache/rocketmq/proxy/remoting/activity/ConsumerManagerActivityTest.java Adds tests asserting failure code/remark and ensuring invalid requests aren’t forwarded.

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

Comment on lines +63 to +68
RemotingCommand response = consumerManagerActivity.processRequest0(ctx, request, ProxyContext.create());

assertThat(response).isNotNull();
assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR);
assertThat(response.getRemark()).isEqualTo("MessageQueue set is empty");
verify(messagingProcessor, never()).request(any(), any(), any(), anyLong());

assertThat(response).isNotNull();
assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR);
assertThat(response.getRemark()).isEqualTo("MessageQueue set is empty");

assertThat(response).isNotNull();
assertThat(response.getCode()).isEqualTo(ResponseCode.SYSTEM_ERROR);
assertThat(response.getRemark()).isEqualTo("MessageQueue set is empty");
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.25%. Comparing base (eddb235) to head (9989011).

Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10783      +/-   ##
=============================================
+ Coverage      48.24%   48.25%   +0.01%     
+ Complexity     13496    13494       -2     
=============================================
  Files           1380     1380              
  Lines         101104   101106       +2     
  Branches       13107    13107              
=============================================
+ Hits           48773    48785      +12     
+ Misses         46350    46333      -17     
- Partials        5981     5988       +7     

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

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review by github-manager-bot

Summary

Fixes ConsumerManagerActivity to return ResponseCode.SYSTEM_ERROR instead of SUCCESS when lock/unlock batch MQ operations receive an empty queue set. Prevents callers from misinterpreting empty operations as successful.

Findings

  • [Info] ConsumerManagerActivity.java:89-92 — Setting SYSTEM_ERROR for empty lock batch is correct. Returning SUCCESS with an empty operation could mask configuration or routing issues.
  • [Info] ConsumerManagerActivity.java:108-111 — Same fix applied to unlock path, ensuring consistency.
  • [Info] New test file ConsumerManagerActivityTest.java provides good coverage for both lock and unlock empty-queue scenarios.

Suggestions

  • Consider whether ILLEGAL_REQUEST or INVALID_PARAMETER might be more semantically accurate than SYSTEM_ERROR for an empty queue set (since it is a client-side input issue rather than a server-side failure). Not blocking — SYSTEM_ERROR is acceptable.

LGTM — correct error code fix with good test coverage.


Automated review by github-manager-bot

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 lock/unlock batch MQ returns response without error code for empty queue set

4 participants