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 09:09:41 UTC
[PR] [ISSUE #833] Validate AI request bodies [rocketmq-dashboard]
Aias00 opened a new pull request, #834:
URL: https://github.com/apache/rocketmq-dashboard/pull/834
### Summary
- Reject missing AI chat and execute request bodies with explicit 400 responses
- Add service-level guards so internal calls cannot reach the LLM gateway with null requests
- Keep AI tool execution behavior unchanged for absent bodies
### Tests
- JAVA_HOME=/Users/aias/Library/Java/JavaVirtualMachines/openjdk-21.0.2/Contents/Home mvn -Dtest=AiServiceTest,AiControllerTest test
Closes #833
--
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 #833] Validate AI request bodies [rocketmq-dashboard]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #834:
URL: https://github.com/apache/rocketmq-dashboard/pull/834#discussion_r3702736422
##########
server/src/main/java/org/apache/rocketmq/studio/ops/ai/AiController.java:
##########
@@ -41,12 +42,18 @@ public class AiController {
private final AiService aiService;
@PostMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
- public SseEmitter chat(@RequestBody ChatDTO request) {
+ public SseEmitter chat(@RequestBody(required = false) ChatDTO request) {
+ if (request == null) {
+ throw new BusinessException(400, "chat request is required");
+ }
return aiService.chat(request);
}
@PostMapping("/execute")
- public Result<AiExecuteResultVO> execute(@RequestBody AiCommandDTO command) {
+ public Result<AiExecuteResultVO> execute(@RequestBody(required = false) AiCommandDTO command) {
+ if (command == null) {
+ throw new BusinessException(400, "AI command request is required");
+ }
return Result.ok(aiService.execute(command));
}
Review Comment:
The null-request validation is duplicated in both controller and service. This increases the chance of divergence (message/code changes in one place but not the other) and adds extra maintenance. Consider keeping `@RequestBody(required = false)` in the controller (so missing bodies bind to null), but delegating the null check to `AiService` only (remove the controller `if (request/command == null)` blocks), or extracting a shared validator/helper to keep behavior consistent.
##########
server/src/main/java/org/apache/rocketmq/studio/ops/ai/AiService.java:
##########
@@ -34,12 +35,18 @@ public class AiService {
public SseEmitter chat(ChatDTO request) {
+ if (request == null) {
+ throw new BusinessException(400, "chat request is required");
+ }
log.info("Chat request received: mode={}, conversationId={}", request.getMode(), request.getConversationId());
return llmGateway.chat(request);
}
public AiExecuteResultVO execute(AiCommandDTO command) {
+ if (command == null) {
+ throw new BusinessException(400, "AI command request is required");
+ }
Review Comment:
Using the literal `400` as a magic number makes intent less explicit and can lead to inconsistent usage across the codebase. Prefer a named constant (e.g., `HttpStatus.BAD_REQUEST.value()`) or a shared app constant for the error code to improve readability and consistency.
##########
server/src/main/java/org/apache/rocketmq/studio/ops/ai/AiService.java:
##########
@@ -34,12 +35,18 @@ public class AiService {
public SseEmitter chat(ChatDTO request) {
+ if (request == null) {
+ throw new BusinessException(400, "chat request is required");
+ }
Review Comment:
Using the literal `400` as a magic number makes intent less explicit and can lead to inconsistent usage across the codebase. Prefer a named constant (e.g., `HttpStatus.BAD_REQUEST.value()`) or a shared app constant for the error code to improve readability and consistency.
--
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 #833] Validate AI request bodies [rocketmq-dashboard]
Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on PR #834:
URL: https://github.com/apache/rocketmq-dashboard/pull/834#issuecomment-5175217721
Superseded by consolidated PR #941, 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
Re: [PR] [ISSUE #833] Validate AI request bodies [rocketmq-dashboard]
Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 closed pull request #834: [ISSUE #833] Validate AI request bodies
URL: https://github.com/apache/rocketmq-dashboard/pull/834
--
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