X-LightYear opened a new issue, #5044:
URL: https://github.com/apache/rocketmq-dashboard/issues/5044
## Problem
The batch import endpoints for Topics and Consumer Groups advertise and
implement per-item result reporting (`imported`, `failed`, and `failures`), but
an invalid item is rejected by Spring validation before the service receives
the batch.
## Reproduction
Send a batch containing one valid row and one row with an empty `name`:
```http
POST /api/topics/import
Content-Type: application/json
{
"instanceId": "instance-a",
"topics": [
{"name": "valid-topic", "writeQueues": 8, "readQueues": 8},
{"name": "", "writeQueues": 8, "readQueues": 8}
]
}
```
The same structure reproduces through `/api/groups/import` with `groups`
instead of `topics`.
## Expected behavior
The valid row should be attempted and the invalid row should be reported in
the response's per-item failure list, for example `imported=1`, `failed=1`, and
`failures[0].index=1`.
## Actual behavior
The endpoint returns HTTP 400 (`name is required`) and the import service is
not called. The valid row is not imported and the batch result does not
identify the failed row.
## Root cause
`ImportTopicsDTO.topics` and `ImportConsumerGroupsDTO.groups` are annotated
with `@Valid`. `CreateTopicDTO` and `CreateConsumerGroupDTO` therefore validate
every nested row at controller argument binding time. A single row-level
constraint violation raises `MethodArgumentNotValidException` before
`MetadataService.importTopics` or `MetadataService.importConsumerGroups` can
execute their per-item loops and build `Import*ResultVO` failure entries.
## Scope
Align the controller boundary with the existing batch service contract while
retaining envelope validation and the maximum batch size. Row-level validation
failures should remain visible as per-item failures, and valid rows must
continue independently.
## Regression evidence
Deterministic MockMvc tests were added locally for both endpoints. On
current master:
-
`TopicControllerTest.importTopicsShouldReturnPerRowFailureInsteadOfRejectingWholeBatch`:
expected 200, actual 400
-
`ConsumerGroupControllerTest.importConsumerGroupsShouldReturnPerRowFailureInsteadOfRejectingWholeBatch`:
expected 200, actual 400
Existing `MetadataServiceTest` coverage already demonstrates that
provider/service failures are collected per row.
## Duplicate search
Searched the repository's open and closed Issues/PRs for:
- `batch import topic partial failure`
- `importTopics validation`
- `consumer group import partial failure`
- `CSV import invalid row`
- `batch import validation`
No matching Issue or PR was found.
--
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]