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

   ### Which Issue(s) This PR Fixes
   
   - Fixes #6844
   
   ### Brief Description
   
   The three paged tools (`rmq.acl.list`, `rmq.audit.list`, 
`rmq.message.query_dlq`) hand `pageSize` to
   services that answer 400 for anything above 100 ("pageSize must be between 1 
and 100"), while their
   published `inputSchema` declared only `minimum: 1`. The schema is the 
contract every caller reads —
   rmqctl's generated catalog is built from it and `ToolSchemaValidator` checks 
agent calls against it
   before a handler runs — so a follow-the-contract call could be built and 
only fail at execution.
   
   - `tool-catalog/tools/{acl,audit,message}.yaml`: `page.pageSize` now 
declares `maximum: 100`, which is
     what the schema validator enforces for every agent call too (fail fast 
with 400 before the handler).
   - rmqctl carries the keyword end to end, exactly the way `minimum` already 
travels: the generator
     accepts and emits it, `catalog.Field` gains `Maximum`/`HasMaximum`, 
`validateValue` rejects
     `--page-size 201` with `INVALID_ARGUMENT` before any request is sent, and 
the flag's usage line
     advertises `(maximum: 100)` next to the minimum.
   - `catalog-verify` (the repo's regeneration check) passes: the committed 
`catalog_gen.go` matches a
     fresh generation, digest included.
   
   ### How Did You Test This Change?
   
   Red first, on the current `rocketmq-studio` tip, with both tests in place 
and only the sources reverted
   (the schemas, the generator, the generated catalog, the validator and the 
usage line):
   
   ```
   $ cd rmqctl && go test ./cmd/ -run TestPagedToolPageSizeCeilingTest
   --- FAIL: TestPagedToolPageSizeCeilingTest (0.00s)
       --- FAIL: .../rmq.acl.list (0.00s)
           catalog_bounds_test.go:45: rmq.acl.list page.pageSize = {... 
Minimum:1 HasMinimum:true Maximum:0 HasMaximum:false ...}; want maximum 100
       --- FAIL: .../rmq.audit.list (0.00s)    (same)
       --- FAIL: .../rmq.message.query_dlq (0.00s)    (same)
   FAIL
   ```
   
   ```
   $ cd server && mvn -Dtest=ToolCatalogTest test        # the tool schema 
validator accepts 101 without the ceiling
   [ERROR] Tests run: 9, Failures: 1, ... 
rejectsPageSizesAboveTheCeilingThePagedServicesEnforceTest
   Expecting code to raise a throwable.
   ```
   
   Green with the change:
   
   ```
   $ cd rmqctl && go test ./...         all packages ok
   $ go vet ./...                       clean
   $ gofmt -l cmd internal scripts      clean
   $ go run ./internal/catalog/generate -input-dir 
../server/src/main/resources/tool-catalog/tools \
           -output internal/catalog/catalog_gen.go -check        
(catalog-verify: exit 0)
   $ cd server && mvn -Dtest='org.apache.rocketmq.studio.ops.ai.tool.**.*Test' 
test
   Tests run: 181, Failures: 0, Errors: 0, Skipped: 0
   BUILD SUCCESS
   ```
   
   The user-visible half, with a binary built from this branch:
   
   ```
   $ rmqctl audit list --page-size 200
   error [INVALID_ARGUMENT]: audit list --page-size must be at most 100
   hint: Check the command flags and required arguments with --help.        # 
refused client-side, no request sent
   
   $ rmqctl audit list --help | grep page-size
         --page-size int           page size (minimum: 1) (maximum: 100)
   
   $ rmqctl audit list --page-size 100 --timeout 1ms     # the boundary is not 
over-restricted
   error [TIMEOUT]: Post "http://.../api/mcp/tools/call": context deadline 
exceeded
   
   $ rmqctl audit list --page-size 0                     # the existing minimum 
is unchanged
   error [INVALID_ARGUMENT]: audit list --page-size must be at least 1
   ```
   
   The bound itself, live and without any credentials (`GET /api/audit-logs` 
runs the same validation the
   tool handler's service does): `pageSize=200` → `400 {"message":"pageSize 
must be between 1 and 100"}`,
   `pageSize=100` → `200`.
   
   ### Checklist
   
   - [x] One coherent change; unrelated modifications are not bundled in
   - [x] Commit subject follows Conventional Commits (`fix(rmqctl): ...`)
   - [x] Tests added or updated for non-trivial changes — 
`TestPagedToolPageSizeCeilingTest` pins the
         declared ceiling, both boundaries and the usage line for the three 
tools;
         `rejectsPageSizesAboveTheCeilingThePagedServicesEnforceTest` pins that 
the schema validator
         refuses 101 and still accepts 100
   - [x] New UI text has both Chinese and English entries under `web/src/i18n/` 
— no web text changed
   - [x] Architecture constraints stay green — no ArchUnit-relevant change; the 
server-side change is a
         resource file plus a test
   - [x] New source files carry the ASF license header — the new Go test file 
does
   - [x] Documentation touched where behaviour changed — the generated catalog 
and the flag usage carry
         the bound; `docs/generated/rmq-tools.*` are unchanged because they do 
not render numeric bounds
   
   Disclosed rather than left to be discovered on merge, because these touch 
the same areas:
   
   - #6726 (mine, open) discloses the *page a table view shows* for the same 
three tools; it touches
     `cmd/catalog_renderers.go` and its test, this one touches the catalog, the 
validator and the usage
     line, so they do not overlap.
   - #5916 (open) edits `cmd/mcp.go` for a snippet that cannot start; unrelated 
to bounds.
   - #6390 (merged) tightened what the generator *validates about its own 
document*; this is the first
     numeric *ceiling* a tool contract declares, and the generator now accepts 
the keyword instead of
     rejecting it as unsupported.
   
   AI assistance: the analysis, the change and the tests were produced with AI 
assistance (an agent
   working in this repository) and reviewed by me before submission; the 
command output above is from the
   actual runs.
   


-- 
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