Frun1na opened a new pull request, #6820:
URL: https://github.com/apache/rocketmq-dashboard/pull/6820
### Which Issue(s) This PR Fixes
- Fixes #6818
### Brief Description
The demo ACL store in `web/src/services/aclService.ts` wrote blank values
into its inventory for
fields the backend refuses: `createAclUser` (`:180`), `createAclRule`
(`:131`) and
`createAndUpdatePlainAccessConfig` (`:255`) all resolved, while the endpoint
answers 400 —
`AclService.createUser` rejects a username that is blank after trimming
(`server/src/main/java/org/apache/rocketmq/studio/instance/acl/AclService.java:236-238`),
`createRule` the same for principal and resource (`:127`, `:130`), and
`createAndUpdatePlainAccessConfig` for accessKey (`:313-315`).
The console can produce exactly these inputs: the ACL page's user dialog and
rule dialog declare
only `required` for their text inputs
(`web/src/pages/instance/acl.tsx:1695`, `:1628`) and the Ant
validator accepts whitespace-only text, and `handlePlainSubmit` trims the
access key before
submitting (`:665`), so a whitespace-only access key arrives as an empty
string. In demo mode the
dialog then toasted "user added" and the ACL user table gained a row with a
blank name, where the
real data source takes the page's existing failure branch.
The three mock branches now call a `requireAclText` guard that mirrors the
backend's
`StringUtils.hasText`: a value blank after trimming is rejected with the
endpoint's message, and
anything else is stored as sent, like the backend. The rejects the same file
already performs
(`secretKey is required for a new plain access account`, `ACL user not
found: <id>`) are unchanged.
User-visible change: in the demo data source a blank ACL username, rule
principal/resource or access
key is rejected instead of being stored. No copy is added; no production
path is affected.
### Other consumers
- `web/src/services/aclService.ts:141`, `:142`, `:192`, `:269` — the three
mock write branches — fixed here.
- `web/src/services/aclService.ts` `updateAclUser`/`updateAclRule` — the
endpoint rejects only a *provided* blank username (`AclService.java:261-263`);
the console's user dialog leaves the name input disabled while editing
(`web/src/pages/instance/acl.tsx:1706`), so no blank update is reachable.
Unchanged.
- `web/src/services/aclService.ts` `createAndUpdatePlainAccessConfig` — its
existing `secretKey is required for a new plain access account` reject is
already correct and pinned by the neighbouring test; unchanged.
- `web/src/services/aclService.ts`
`deleteAclRule`/`deleteAclUser`/`getAclUserCredentials`/`updateAclRule`/`updateAclUser`
— already reject ids the mock store does not hold, with the endpoint's
messages (pinned by `rejects deletion of missing ACL records`). Unchanged.
- `web/src/pages/instance/acl.tsx:1695`, `:1628`, `:1745` — the forms'
`required` rules are console-side validation and stay as they are: they accept
whitespace, but the 400 comes from the service layer, and any other client
reaches that layer directly, so the mock has to mirror it. Tightening the forms
is a separate, larger UX change.
- `web/src/services/opsService.ts`, `consumerService.ts`, `topicService.ts`,
`instanceService.ts` — their mock stores already reject blank required text or
are covered by open changes (#6351 for the delete family, #6146/#5881 for the
paged mocks). Not touched here.
### How Did You Test This Change?
```
$ cd web && npx eslint src/services/aclService.test.ts
src/services/aclService.ts
# clean
$ cd web && npx prettier --check src/services/aclService.test.ts
src/services/aclService.ts
Checking formatting...
All matched files use Prettier code style!
$ cd web && npx vitest run src/services/aclService.test.ts --maxWorkers=1
--fileParallelism=false
✓ src/services/aclService.test.ts (11 tests) 11ms
Test Files 1 passed (1)
Tests 11 passed (11)
$ cd web && npx vitest related --run src/services/aclService.test.ts
--maxWorkers=1 --fileParallelism=false
Test Files 1 passed (1)
Tests 11 passed (11)
$ cd web && npx vitest run src/pages/instance/__tests__/AclPage.test.tsx
--maxWorkers=1 --fileParallelism=false
Test Files 1 passed (1)
Tests 29 passed (29)
$ cd web && npx tsc -b
# clean
```
The new test fails without the fix (this is the mutation check:
`web/src/services/aclService.ts` is
restored to the version without the guard, the test file is kept):
```
$ cd web && npx vitest related --run src/services/aclService.test.ts
--maxWorkers=1 --fileParallelism=false
FAIL src/services/aclService.test.ts > ACL service mock data > rejects the
blank ACL fields the backend requires text for
AssertionError: promise resolved "{ id: 1792091071509, …(6) }" instead of
rejecting
- Error {
- "message": "rejected promise",
+ {
+ "accessKey": "",
+ "admin": false,
+ "clusters": [],
+ "gmtCreate": "2026-10-15T19:04:31.509Z",
+ "id": 1792091071509,
+ "secretKey": "",
+ "username": " ",
+ }
Test Files 1 failed (1)
Tests 1 failed | 10 passed (11)
```
The assertion is that a whitespace-only username, principal, resource and
access key reject while
`listAclUsers()` stays unchanged, so it can only pass once the mock refuses
the values the endpoint
refuses; the received object in the mutation output is the nameless user row
the store used to keep.
`keeps accepting an identity whose text is not blank` is the control that
fails if the guard is
widened into a trim, and the ten neighbouring cases pin the rest of the
service.
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [ ] New UI text has both Chinese and English entries under `web/src/i18n/`
- [ ] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [ ] New source files carry the ASF license header
- [ ] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
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]