unbridled-41 opened a new issue, #5931:
URL: https://github.com/apache/rocketmq-dashboard/issues/5931

   ### Studio Version
   branch: `rocketmq-studio` @ `7e7aa344` (the revision verified; the branch is 
based on it)
   deployed as: not required to reproduce
   
   ### Runtime Environment
   
   Reproduced with the backend tests (`cd server && mvn -o -B -ntp test 
-Dtest='RocketMQAdminClientImplTest'`).
   
   ### Connected RocketMQ Cluster
   
   Any cluster; the invalid name never reaches a broker successfully.
   
   ### Describe the Bug
   
   The write paths only trim the name (`ResourceOwnershipGuard.requireText`) 
and let the broker decide, but the broker's validation runs at the RPC - after 
this code has already inserted the ownership row (`executeResourceWrite` -> 
`ownershipGuard.write` -> the RPC). Two failure modes follow:
   
   - A name longer than the 255-character storage column makes that insert 
throw `DataIntegrityViolationException`, which no handler maps, so the API 
answers `500 Internal Server Error` with no reason.
   - A name that fits the column but not the broker (128..255 characters, or 
any name outside `^[%|a-zA-Z0-9_-]+$`, e.g. `my topic` or `订单`) leaves the 
claim behind as a PENDING row. The topic/group list filters by instance only, 
so the never-created resource shows up in the console with 0 queues and blocks 
that name in every other instance until someone deletes the phantom.
   
   The console already enforces the same bounds client-side 
(`web/src/utils/resourceCsvImport.ts`: topic 127, group 120), so only direct 
API/AI/import callers hit this.
   
   ### Steps to Reproduce
   
   1. `POST /api/topics/create` with `{"name":"my 
topic","instanceId":"<apache>"}`.
   2. The broker rejects it; the response is a 500 (or, for a 
128..255-character name, the topic appears in the list with 0 queues even 
though it does not exist).
   
   ### What Did You Expect to See?
   
   A 400 naming the rule, before anything is written.
   
   ### What Did You See Instead?
   
   A generic 500, or a phantom entry in the inventory.
   
   ### Evidence
   
   - `server/.../provider/apache/RocketMQAdminClientImpl.java` 
(`createTopic`/`updateTopic`/`createConsumerGroup`/`updateConsumerGroup`), 
`server/.../instance/ResourceOwnershipGuard.java`, 
`TopicValidator.validateTopic` (the broker's own rules; 127 characters, 
`^[%|a-zA-Z0-9_-]+$`).
   - `cd server && mvn -o -B -ntp test 
-Dtest='RocketMQAdminClientImplTest#createTopicRejectsAnIllegalNameBeforeWritingAnythingTest'`
 - before the fix there is no 400.
   
   ### Impact
   
   Invalid input answered with a 500 instead of a 400, and for a subset of 
inputs a phantom PENDING resource that the inventory shows as real and that 
blocks the name elsewhere.
   
   ### Acceptance Criteria
   
   - An illegal topic or group name is rejected with 400 and the broker's own 
message before any ownership write or broker call, while names the broker 
accepts (including 127 characters and underscores) still work, with regression 
tests.
   
   **Corresponding PR:** #ISSUEPR#
   


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