fix(mcp): NPE in ListStreamsTool when stream description is null#25217
Merged
Conversation
bernd
requested changes
Apr 8, 2026
| "id", stream.getId(), | ||
| "title", stream.getTitle(), | ||
| "description", stream.getDescription(), | ||
| "description", Optional.ofNullable(stream.getDescription()).orElse(""), |
Member
There was a problem hiding this comment.
You can use Objects.requireNonNullElse(stream.getDescription(), "") to avoid the Optional object creation.
Contributor
Author
There was a problem hiding this comment.
thanks for the feedback! I just changed it. Please take a look when you can
bernd
approved these changes
Apr 22, 2026
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Handle nullable
descriptionfield inListStreamsTool.apply().StreamDTO.description()andStreamImpl.description()are both annotated@Nullable, but the value was passed directly intoMap.of()which throwsNullPointerExceptionon null values. Wrapped withOptional.ofNullable(...).orElse("")to safely default to an empty string.Motivation and Context
When any stream has no description, the
list_streamsMCP tool call fails with"Tool call failed: null", making the entire tool unusable if even a single stream lacks a description.Fixes #25214
How Has This Been Tested?
Manual testing: created a stream without a description and verified the
list_streamsMCP tool returns all streams successfully.Screenshots (if appropriate):
N/A
Types of changes
Checklist: