zjncs opened a new pull request, #5707:
URL: https://github.com/apache/rocketmq-dashboard/pull/5707
### What
`ToolSchemaValidator` — the runtime guard that every tool argument and every
tool output satisfies its catalog schema — was only exercised incidentally
through two message-query limit cases in `ToolCatalogTest`. This adds
`ToolSchemaValidatorTest` with 9 tests against a purpose-built one-tool
catalog, pinning the rest of the contract.
### Why
Two of its behaviors had no coverage at all: the **output** side (including
the subtle two-mapper dance) and the **fail-fast at construction**. The output
path normalizes through the application's configured Jackson 2 mapper before
the bare Jackson 3 validation mapper sees the value, so validation observes the
same wire names the HTTP and MCP responses use — nothing pinned that, and it is
exactly the kind of dance a refactor would "simplify" away.
### What is pinned
- input that satisfies the schema passes; input **missing a required
argument**, **adding an unknown argument**, or **carrying a wrongly typed
argument** fails with the 400 `INVALID_ARGUMENT` `ToolExecutionException`
naming the tool;
- output that satisfies the schema passes; output violating it fails with
the `IllegalStateException` naming the tool;
- **the Jackson 2 normalization**: a DTO component `physicalCluster` reaches
the schema as `physical_cluster` under the application's SNAKE_CASE strategy —
the bare Jackson 3 mapper would see the component name instead;
- **fail-fast at construction**: a catalog schema that is not valid JSON
Schema (`minProperties: three`, a string where an integer is required) is
rejected at startup. The catalog's own schema only checks that `inputSchema` is
an object, so the meta-schema check is the only gate.
### Verification
- New tests on unmodified code: **9/9 green** (`mvn test
-Dtest=ToolSchemaValidatorTest`).
- Discriminating mutations on `ToolSchemaValidator`, build result verified
red each time:
1. the Jackson 2 normalization skipped so the bare Jackson 3 mapper sees
component names — the normalization test reddens;
2. the output rejection swallowed — the output test reddens;
3. the meta-schema check removed — the fail-fast test reddens.
- Restored: 9/9 green. Test-only change; no product code touched.
--
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]