Frun1na opened a new issue, #6824: URL: https://github.com/apache/rocketmq-dashboard/issues/6824
### Before Creating the Bug Report - [x] I have searched the [open issues](https://github.com/apache/rocketmq-dashboard/issues) of this repository and believe that this is not a duplicate. - [x] This is a defect in RocketMQ Studio, not a usage question and not a defect in another Apache RocketMQ repository. - [x] I can reproduce this on the current `rocketmq-studio` branch, or I have stated the exact version I am running below. ### Studio Version branch: rocketmq-studio git commit id: a92c2314 deployed as: reproduced by a unit test against that commit ### Runtime Environment OS: Ubuntu on WSL2 (unit-test reproduction) MySQL: not applicable — the defect is in the web demo (mock) data source browser (for UI issues): not applicable — the defect is reproduced at the service layer ### Connected RocketMQ Cluster not applicable — reproduced with the bundled demo data source in a unit test ### Describe the Bug In demo-data mode `createInstance` writes an instance whose name or endpoint is blank, while the endpoint refuses the same input. `web/src/services/instanceService.ts:90-102` builds the store row with `name: data.name || ''` and `endpoint: data.endpoint || ''` and pushes it, so a whitespace-only name or endpoint is accepted. The endpoint answers 400 instead: `InstanceService.createApacheInstance` registers a manual instance through `requireInstanceName` (`server/src/main/java/org/apache/rocketmq/studio/instance/InstanceService.java:590-599`, blank after trimming -> "InstanceVO name is required", stores the trimmed value) and `requireValidEndpoint` (`:577-588`, blank -> "InstanceVO endpoint is required", stores the trimmed value). The registration dialog can produce both inputs: the name input declares only `required` and `max: 64`, the endpoint input only `required` (`web/src/pages/instance/index.tsx:958-965`, `:987-992`), and the Ant validator accepts a whitespace-only value, which `handleCreate` submits unchanged (`:364-382`). ### Steps to Reproduce 1. Start the web console in demo (mock) data-source mode and open the Instances page. 2. "Add Instance": give the name a single space (or leave the name valid and give the endpoint a single space), fill the other fields and submit. 3. Observe: the instance is created, the success toast prints an empty name, and the list shows a row without a name (or without an endpoint). The same at the service level: ``` $ cd web && npx vitest run src/services/instanceService.test.ts FAIL src/services/instanceService.test.ts > instanceService mock instances > rejects the blank name and endpoint the API requires AssertionError: promise resolved "{ id: 1792091664145, name: ' ', …(8) }" instead of rejecting ``` ### What Did You Expect to See? The demo instance register rejects the blank name/endpoint with the endpoint's own 400 message ("InstanceVO name is required" / "InstanceVO endpoint is required") and stores the trimmed value, so it mirrors what a real instance does. ### What Did You See Instead? `createInstance({ name: ' ', … })` resolves with the row `{ name: ' ', endpoint: '10.0.1.90:9876', … }`, so the demo reports success and the instance list gains a row whose name is blank (and the name-keyed instance routes/selectors resolve to that blank name). A whitespace-only endpoint behaves the same way. ### Additional Context A fix with a regression test follows in a pull request. ### Are You Willing to Submit a Pull Request? - [x] Yes, I am willing to submit a pull request. -- 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]
