[ISSUE #10795] Validate proxy check client config - #10796
Conversation
There was a problem hiding this comment.
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
enablePropertyFilterproxy 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.
| CheckClientRequestBody requestBody = CheckClientRequestBody.decode(request.getBody(), | ||
| CheckClientRequestBody.class); | ||
| if (requestBody != null && requestBody.getSubscriptionData() != null) { |
| 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; | ||
| } |
| 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; |
| @Before | ||
| public void setUp() { | ||
| this.clientManagerActivity = new ClientManagerActivity(null, messagingProcessor, remotingChannelManager); | ||
| } |
| @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); | ||
| } |
| 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 Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
Which Issue(s) This PR Fixes
Fixes #10795
Brief Description
CHECK_CLIENT_CONFIGrequest bodies instead of always returning successenablePropertyFilteris disabled, matching the default broker behaviorSUBSCRIPTION_PARSE_FAILEDon parse errorsHow Did You Test This Change?
mvn -pl proxy -Dtest=ClientManagerActivityTest testThe 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.