fix: Add null check for session in WebFluxSseServerTransportProvider (#138)
Add error handling to return a 404 NOT_FOUND response when a request is made with a non-existent session ID. This prevents potential NullPointerExceptions when processing requests with invalid session IDs. Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
parent
391ec19fdc
commit
2895d1589a
1 changed files with 5 additions and 0 deletions
|
|
@ -306,6 +306,11 @@ public class WebFluxSseServerTransportProvider implements McpServerTransportProv
|
|||
|
||||
McpServerSession session = sessions.get(request.queryParam("sessionId").get());
|
||||
|
||||
if (session == null) {
|
||||
return ServerResponse.status(HttpStatus.NOT_FOUND)
|
||||
.bodyValue(new McpError("Session not found: " + request.queryParam("sessionId").get()));
|
||||
}
|
||||
|
||||
return request.bodyToMono(String.class).flatMap(body -> {
|
||||
try {
|
||||
McpSchema.JSONRPCMessage message = McpSchema.deserializeJsonRpcMessage(objectMapper, body);
|
||||
|
|
|
|||
Loading…
Reference in a new issue