Skip to content

fix(mcp): NPE in ListStreamsTool when stream description is null#25217

Merged
monrax merged 4 commits into
masterfrom
fix/mcp-list-streams-null-desc
Apr 22, 2026
Merged

fix(mcp): NPE in ListStreamsTool when stream description is null#25217
monrax merged 4 commits into
masterfrom
fix/mcp-list-streams-null-desc

Conversation

@monrax
Copy link
Copy Markdown
Contributor

@monrax monrax commented Mar 4, 2026

Description

Handle nullable description field in ListStreamsTool.apply(). StreamDTO.description() and StreamImpl.description() are both annotated @Nullable, but the value was passed directly into Map.of() which throws NullPointerException on null values. Wrapped with Optional.ofNullable(...).orElse("") to safely default to an empty string.

Motivation and Context

When any stream has no description, the list_streams MCP 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_streams MCP tool returns all streams successfully.

Screenshots (if appropriate):

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have requested a documentation update.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@monrax monrax requested a review from bernd March 4, 2026 11:30
"id", stream.getId(),
"title", stream.getTitle(),
"description", stream.getDescription(),
"description", Optional.ofNullable(stream.getDescription()).orElse(""),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use Objects.requireNonNullElse(stream.getDescription(), "") to avoid the Optional object creation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the feedback! I just changed it. Please take a look when you can

@monrax monrax requested a review from bernd April 22, 2026 09:45
@monrax monrax merged commit c0c1f8e into master Apr 22, 2026
22 of 23 checks passed
@monrax monrax deleted the fix/mcp-list-streams-null-desc branch April 22, 2026 11:23
monrax added a commit that referenced this pull request Apr 23, 2026
) (#25768)

* fix(mcp): NPE in ListStreamsTool when stream description is null

* Avoid unnecessary Optional object creation

* add changelog

(cherry picked from commit c0c1f8e)

Co-authored-by: Ramón Márquez <ramon.marquez@graylog.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP(ListStreamsTool): NPE when a stream has Null description

2 participants