tju-yxq opened a new pull request, #2421:
URL: https://github.com/apache/rocketmq-dashboard/pull/2421
## Why
`POST /api/instances/delete-batch` iterates over the raw request list and
only skips null/blank entries. Repeated IDs are not normalized or de-duplicated:
```java
for (String instanceId : instanceIds) {
if (instanceId == null || instanceId.isBlank()) {
continue;
}
deleteInstance(resolveInstanceId(instanceId.trim()));
deleted++;
}
```
A request such as `["inst-a", "inst-a"]` processes the same row twice. A
request such as `["", " "]` is accepted as a non-empty batch and returns
`deleted=0, failed=[]` instead of a validation error.
Closes #2420.
## Change
`InstanceService.deleteInstances` now normalizes the request once before
deletion:
- null entries are ignored;
- IDs are trimmed;
- empty IDs are discarded;
- repeated IDs are de-duplicated;
- if no usable ID remains, the request returns HTTP 400 with the existing
`Instance IDs are required` error.
Deletion behavior for distinct IDs is unchanged. Existing managed-resource
checks, data-source binding cleanup, endpoint cleanup, audits, and per-instance
failure reporting remain exactly as before.
## Verification
Focused tests:
```text
mvn "-Dtest=InstanceServiceTest#deleteInstances*" test
4 tests
0 failures
0 errors
BUILD SUCCESS
Checkstyle: 0 violations
```
Full backend suite:
```text
mvn -DskipTests=false test
1,483 tests
0 failures
0 errors
BUILD SUCCESS
```
`git diff --check` passes.
The new tests cover:
- repeated and whitespace-padded IDs resolve to one deletion with no
duplicate failure;
- an all-null/blank/empty request returns HTTP 400;
- the existing valid/missing mixed batch behavior remains covered.
No frontend change is needed because the normal UI sends AntD table row keys
and does not intentionally create duplicates. This PR fixes the directly
callable API contract.
--
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]