zjncs opened a new pull request, #4115:
URL: https://github.com/apache/rocketmq-dashboard/pull/4115

   ### Motivation
   
   `rmq.topic.list` and `rmq.group.list` always fail with `404 Instance not 
found: DefaultCluster` in the default deployment (namesrv-only, no registered 
instances).
   
   `MetadataService.listTopicsPage(instanceId, clusterId, ...)` routes a 
**blank instance id + non-blank cluster id** to the legacy cluster-scoped read 
(the branch commented `// legacy cluster-scoped read kept for AI tool 
handlers`). But both handlers pass the tool's `cluster` input into the 
**first** (instanceId) slot and `null` into the second:
   
   ```java
   // TopicListToolHandler / ConsumerGroupListToolHandler
   metadataService.listTopicsPage(clusterId, null, type, search, page, 
pageSize);
   ```
   
   A cluster name such as `DefaultCluster` therefore reaches 
`providerRegistry.byInstanceId(...)`, which throws `404 "Instance not found: 
DefaultCluster"` for any value that is not a registered instance id.
   
   This is a regression from #3052: the handlers previously called the 3-arg 
`listTopics(clusterId, type, search)` overload, which delegates to 
`listTopics(null, clusterId, ...)` — the old first parameter *was* the cluster 
id, and #3052 mapped it onto the new signature's renamed first parameter 
(`instanceId`) unchanged:
   
   ```diff
   -        return metadataService.listTopics(clusterId, type, search).stream()
   +        PageResult<TopicVO> page = metadataService.listTopicsPage(
   +                clusterId, null, type, search, 
ToolListPagination.page(input), ToolListPagination.pageSize(input));
   ```
   
   The same request proves the contradiction internally: 
`ToolGatewayService.enforceCapabilities` resolves the same `cluster` input 
through `clusterService.getCluster(...)` (cluster-name space) and succeeds, 
then the handler 404s on the same value in the instance-id space.
   
   ### Modifications
   
   - `TopicListToolHandler` / `ConsumerGroupListToolHandler`: pass `null` as 
the instance id and the tool's `cluster` input as the cluster id, restoring the 
pre-#3052 routing and making the cluster-scoped branch reachable again.
   - `ToolGatewayServiceTest`: updated the two stubs that pinned the previous 
slotting.
   
   ### Verification
   
   - New `TopicListToolHandlerTest` / `ConsumerGroupListToolHandlerTest` 
(modeled on `MessageQueryToolHandlerTest`) stub 
`metadataService.listTopicsPage(isNull(), eq("DefaultCluster"), ...)` and 
verify the delegation.
     - Before the fix: both fail with `PotentialStubbingProblem` — the handlers 
invoke `("DefaultCluster", null, ...)`.
     - After the fix: both pass.
   - `mvn -f server/pom.xml test 
-Dtest='TopicListToolHandlerTest,ConsumerGroupListToolHandlerTest,ToolGatewayServiceTest'`
 → **Tests run: 34, Failures: 0, Errors: 0**.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to