fix: harden gRPC route and assignment Broker validation - #10771
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens Proxy gRPC RouteActivity#queryAssignment against malformed/partial route metadata by skipping queue rows that don’t have a master broker entry, avoiding exceptional failures during protobuf MessageQueue construction and instead returning the existing controlled FORBIDDEN response when no valid assignments remain.
Changes:
- Skip queue rows where
brokerIdMap.get(MixAll.MASTER_ID)returnsnullinRouteActivity#queryAssignment. - Add a regression test covering route metadata that only contains non-master broker IDs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| proxy/src/main/java/org/apache/rocketmq/proxy/grpc/v2/route/RouteActivity.java | Skips queue rows lacking a master broker to prevent null broker usage when building assignments. |
| proxy/src/test/java/org/apache/rocketmq/proxy/grpc/v2/route/RouteActivityTest.java | Adds coverage for the “missing master broker” route-metadata scenario, asserting a controlled FORBIDDEN response with no assignments. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #10771 +/- ##
=============================================
- Coverage 48.62% 48.51% -0.11%
+ Complexity 13692 13654 -38
=============================================
Files 1381 1381
Lines 101464 101466 +2
Branches 13187 13188 +1
=============================================
- Hits 49337 49228 -109
- Misses 46142 46226 +84
- Partials 5985 6012 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Review by github-manager-bot
Summary
Adds null check for broker after brokerIdMap.get(MixAll.MASTER_ID) in DefaultConsumerAssignor.queryAssignment(), preventing NullPointerException when the master broker is missing from the route result.
Findings
- [Info] The fix is correct and minimal. Returning a FORBIDDEN result when the master broker is unavailable is the right behavior — the client should not proceed with assignment from an incomplete route.
- [Info] Test coverage verifies that a missing master broker results in FORBIDDEN with no assignments.
Suggestions
- None. Clean, targeted fix.
LGTM.
Automated review by github-manager-bot
RockteMQ-AI
left a comment
There was a problem hiding this comment.
Summary
Defensive fix with proper validation and test coverage. LGTM.
Automated review by github-manager-bot
609f468 to
2530042
Compare
Summary
Validation
mvn -q -pl proxy -am -Dtest=RouteActivityTest -DfailIfNoTests=false testCloses #10770
Closes #10768