Skip to content

[ISSUE #10795] Validate proxy check client config - #10796

Open
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-check-client-config-10795
Open

[ISSUE #10795] Validate proxy check client config#10796
Aias00 wants to merge 2 commits into
apache:developfrom
Aias00:fix/proxy-check-client-config-10795

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Which Issue(s) This PR Fixes

Fixes #10795

Brief Description

  • Validate Proxy remoting CHECK_CLIENT_CONFIG request bodies instead of always returning success
  • Keep TAG expressions accepted
  • Reject SQL/property filters when enablePropertyFilter is disabled, matching the default broker behavior
  • Compile SQL/property filter expressions when enabled and return SUBSCRIPTION_PARSE_FAILED on parse errors
  • Add regression coverage for TAG, disabled property filter, and invalid SQL expression cases

How Did You Test This Change?

  • mvn -pl proxy -Dtest=ClientManagerActivityTest test

The target test passed: 3 tests, 0 failures, 0 errors. The Maven run completed with BUILD SUCCESS; the output still includes existing Jacoco/JDK17 instrumentation warnings.

Copilot AI review requested due to automatic review settings August 3, 2026 14:20

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 tightens proxy-side validation for CHECK_CLIENT_CONFIG by validating subscription filter requests (TAG vs SQL/property) and aligning behavior with broker defaults, plus adding regression tests.

Changes:

  • Add request-body decoding and validation in ClientManagerActivity#checkClientConfig (accept TAG, reject/validate SQL/property).
  • Introduce enablePropertyFilter proxy config gate for SQL/property filter checks.
  • Add unit tests covering TAG acceptance, disabled property filter rejection, and invalid SQL parse failures.

Reviewed changes

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

File Description
proxy/src/main/java/org/apache/rocketmq/proxy/remoting/activity/ClientManagerActivity.java Decode and validate CHECK_CLIENT_CONFIG bodies; gate SQL/property filters behind config and compile expressions.
proxy/src/main/java/org/apache/rocketmq/proxy/config/ProxyConfig.java Add enablePropertyFilter configuration flag and accessors.
proxy/src/test/java/org/apache/rocketmq/proxy/remoting/activity/ClientManagerActivityTest.java Add regression tests for TAG acceptance, disabled property filter handling, and SQL parse failures.

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

Comment on lines +166 to +168
CheckClientRequestBody requestBody = CheckClientRequestBody.decode(request.getBody(),
CheckClientRequestBody.class);
if (requestBody != null && requestBody.getSubscriptionData() != null) {
Comment on lines +176 to +181
if (!ConfigurationManager.getProxyConfig().isEnablePropertyFilter()) {
response.setCode(ResponseCode.SYSTEM_ERROR);
response.setRemark("The proxy does not support consumer to filter message by "
+ subscriptionData.getExpressionType());
return response;
}
Comment on lines +186 to +190
log.warn("Client {}@{} filter message, but failed to compile expression! sub={}, error={}",
requestBody.getClientId(), requestBody.getGroup(), requestBody.getSubscriptionData(), e.getMessage());
response.setCode(ResponseCode.SUBSCRIPTION_PARSE_FAILED);
response.setRemark(e.getMessage());
return response;
Comment on lines +47 to +50
@Before
public void setUp() {
this.clientManagerActivity = new ClientManagerActivity(null, messagingProcessor, remotingChannelManager);
}
Comment on lines +69 to +77
@Test
public void testCheckClientConfigRejectsInvalidPropertyFilterExpression() {
ConfigurationManager.getProxyConfig().setEnablePropertyFilter(true);

RemotingCommand response = clientManagerActivity.checkClientConfig(null,
createRequest(ExpressionType.SQL92, "a = "), ProxyContext.create());

assertThat(response.getCode()).isEqualTo(ResponseCode.SUBSCRIPTION_PARSE_FAILED);
}
Comment on lines +183 to +191
try {
FilterFactory.INSTANCE.get(subscriptionData.getExpressionType()).compile(subscriptionData.getSubString());
} catch (Exception e) {
log.warn("Client {}@{} filter message, but failed to compile expression! sub={}, error={}",
requestBody.getClientId(), requestBody.getGroup(), requestBody.getSubscriptionData(), e.getMessage());
response.setCode(ResponseCode.SUBSCRIPTION_PARSE_FAILED);
response.setRemark(e.getMessage());
return response;
}
@codecov-commenter

codecov-commenter commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.23529% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.29%. Comparing base (eddb235) to head (f5f6f3b).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...proxy/remoting/activity/ClientManagerActivity.java 86.66% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10796      +/-   ##
=============================================
- Coverage      48.34%   48.29%   -0.06%     
+ Complexity     13527    13513      -14     
=============================================
  Files           1380     1380              
  Lines         101104   101171      +67     
  Branches       13107    13124      +17     
=============================================
- Hits           48882    48857      -25     
- Misses         46267    46327      +60     
- 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 CHECK_CLIENT_CONFIG always returns success

3 participants