You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "Aias00 (via GitHub)" <gi...@apache.org> on 2026/08/03 13:23:04 UTC
[PR] [ISSUE #860] Validate null cluster config requests [rocketmq-dashboard]
Aias00 opened a new pull request, #861:
URL: https://github.com/apache/rocketmq-dashboard/pull/861
### Summary
- reject JSON `null` bodies for the cluster config update API at the controller boundary
- keep existing field validation behavior unchanged
- add WebMvc coverage to ensure null requests return 400 without invoking the service layer
### Tests
- `JAVA_HOME=/Users/aias/Library/Java/JavaVirtualMachines/openjdk-21.0.2/Contents/Home mvn -Dtest=ClusterControllerTest test`
Closes #860
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #860] Validate null cluster config requests [rocketmq-dashboard]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #861:
URL: https://github.com/apache/rocketmq-dashboard/pull/861#discussion_r3704394218
##########
server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterController.java:
##########
@@ -55,7 +56,8 @@ public Result<ClusterVO> getCluster(@PathVariable String id) {
}
@PostMapping("/config/update")
- public Result<ClusterVO> updateClusterConfig(@Valid @RequestBody UpdateConfigDTO command) {
+ public Result<ClusterVO> updateClusterConfig(@Valid @RequestBody(required = false) UpdateConfigDTO command) {
+ requireUpdateConfigCommand(command);
return Result.ok(clusterService.updateClusterConfig(command));
}
Review Comment:
Setting `@RequestBody(required = false)` changes behavior beyond JSON `null`: requests with a missing/empty body will now reach the controller and be mapped to `null`, producing your `BusinessException` response instead of Spring’s default `HttpMessageNotReadableException` handling. If the intent is strictly to reject JSON `null` while keeping prior behavior for missing bodies, consider keeping `required = true` and enforcing non-null via Bean Validation on the parameter (e.g., `@NotNull`) with method validation enabled, or handling only the JSON-`null` case via message conversion/exception handling.
##########
server/src/main/java/org/apache/rocketmq/studio/cluster/broker/ClusterController.java:
##########
@@ -68,4 +70,10 @@ public Result<Map<String, Object>> restartBroker(@PathVariable String clusterId,
"message", "Broker restart initiated for " + name
));
}
+
+ private void requireUpdateConfigCommand(UpdateConfigDTO command) {
+ if (command == null) {
+ throw new BusinessException(400, "Cluster config update request is required");
+ }
+ }
Review Comment:
Avoid the magic number `400` here; it’s clearer and less error-prone to reference a shared constant (e.g., `HttpStatus.BAD_REQUEST.value()`) or a project-level error code enum/constant if one exists. This also makes refactors and consistency checks easier across controllers.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #860] Validate null cluster config requests [rocketmq-dashboard]
Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 closed pull request #861: [ISSUE #860] Validate null cluster config requests
URL: https://github.com/apache/rocketmq-dashboard/pull/861
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ISSUE #860] Validate null cluster config requests [rocketmq-dashboard]
Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #861:
URL: https://github.com/apache/rocketmq-dashboard/pull/861#issuecomment-5174171893
Superseded by consolidated PR #929, which contains this change and has passing checks. Closing this narrower PR to keep review focused.
--
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: commits-unsubscribe@rocketmq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org