zjncs opened a new pull request, #4117:
URL: https://github.com/apache/rocketmq-dashboard/pull/4117
### Motivation
`rmq.dashboard.summary` and `rmq.group.list` fail output validation (HTTP
500 `IllegalStateException: Tool output validation failed`) whenever the data
behind a declared `type: integer` count is unavailable — which the producers
deliberately encode as `null`:
- `rmq.dashboard.summary`: `RocketMQDashboardProvider` reports
proxy/name-server topology counts as `null` for V5 clusters
(`.proxies(clusterType == ClusterType.V4_DIRECT ? 0 : null)`), for aggregate
mode (`.totalProxies(null)`), and in the degraded no-namesrv path (both
`totalProxies(null)` / `totalNameServers(null)`).
`DashboardControllerTest.getDashboardShouldPreserveUnavailableTopologyCounts`
pins these nulls as the intended HTTP semantics — only the tool schema rejects
them.
- `rmq.group.list`: #3988 deliberately changed the handler projection to
`totalLag == ConsumerLagResolver.UNKNOWN ? null : totalLag` (unknown lag for
5.0 gRPC consumers), but the output schema was not updated — so any cluster
containing one such group makes the whole listing fail with a 500, exactly when
the user most needs it.
`objectMapper.valueToTree` keeps the keys (`{"totalLag": null}`) and the
schema validator rejects `null` against `type: integer`.
### Modifications
In `tool-catalog/rmq-tools.yaml`, the four affected fields become `type:
['integer', 'null']` (keys stay in `required`, so they must still be present):
- `rmq.dashboard.summary` → `cluster.proxies`, `stats.totalProxies`,
`stats.totalNameServers`
- `rmq.group.list` → `items[].totalLag`
### Verification
Two new `ToolGatewayServiceTest` cases mirroring the producer semantics:
- `executesDashboardSummaryWhenTopologyCountsAreUnavailable` (dashboard with
`proxies/totalProxies/totalNameServers = null`)
- `executesConsumerGroupListWhenLagIsUnknown` (group with `totalLag =
ConsumerLagResolver.UNKNOWN`)
Before the fix both fail with the production error, e.g.:
```
IllegalStateException: Tool output validation failed for
rmq.dashboard.summary:
[/cluster/proxies: null found, integer expected,
/stats/totalNameServers: null found, integer expected,
/stats/totalProxies: null found, integer expected]
IllegalStateException: Tool output validation failed for rmq.group.list:
[/items/0/totalLag: null found, integer expected]
```
After the fix: `mvn -f server/pom.xml test
-Dtest='ToolGatewayServiceTest,ToolCatalogTest'` → **Tests run: 40, Failures:
0, Errors: 0** (catalog meta-schema validation included).
--
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]