This is an automated email from the ASF dual-hosted git repository.
lizhimins pushed a commit to branch rocketmq-studio
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git
The following commit(s) were added to refs/heads/rocketmq-studio by this push:
new ccdf7909 fix(api): return 400 for invalid request parameters (#1080)
ccdf7909 is described below
commit ccdf790961d585bf49b41822db15b2c09fbd8e55
Author: yyqdbngt <[email protected]>
AuthorDate: Thu Aug 6 16:18:56 2026 +0800
fix(api): return 400 for invalid request parameters (#1080)
Co-authored-by: yyqdbngt <[email protected]>
---
.../rocketmq/studio/common/exception/GlobalExceptionHandler.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git
a/server/src/main/java/org/apache/rocketmq/studio/common/exception/GlobalExceptionHandler.java
b/server/src/main/java/org/apache/rocketmq/studio/common/exception/GlobalExceptionHandler.java
index 144ad7b6..ca390d77 100644
---
a/server/src/main/java/org/apache/rocketmq/studio/common/exception/GlobalExceptionHandler.java
+++
b/server/src/main/java/org/apache/rocketmq/studio/common/exception/GlobalExceptionHandler.java
@@ -25,9 +25,11 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
+import
org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
@RestControllerAdvice
public class GlobalExceptionHandler {
@@ -72,6 +74,13 @@ public class GlobalExceptionHandler {
return Result.error(HttpStatus.BAD_REQUEST.value(), "Invalid request
body");
}
+ @ExceptionHandler({MethodArgumentTypeMismatchException.class,
MissingServletRequestParameterException.class})
+ @ResponseStatus(HttpStatus.BAD_REQUEST)
+ public Result<?> handleBadRequestParameterException(Exception ex) {
+ log.warn("Invalid request parameter: {}", ex.getMessage());
+ return Result.error(HttpStatus.BAD_REQUEST.value(), "Invalid request
parameter");
+ }
+
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public Result<?> handleException(Exception ex) {