Skip to content

NullPointerException in McpClientSession #605

Open

Description

@vorburger

Please do a quick search on GitHub issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description

In enola-dev/enola#1862, I've run into:

java.lang.NullPointerException: data
	at java.base/java.util.Objects.requireNonNull(Objects.java:259)
	at reactor.core.publisher.FluxHandle$HandleSubscriber.next(FluxHandle.java:251)
	at io.modelcontextprotocol.spec.McpClientSession.lambda$sendRequest$12(McpClientSession.java:280)
	at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:113)
	at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99)
	at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.onNext(FluxTimeout.java:181)
	at reactor.core.publisher.MonoCreate$DefaultMonoSink.success(MonoCreate.java:176)

I guess that this means that this is null?

Environment

0.14.1

Steps to reproduce

Unfortunately I'm unable to reproduce it locally even myself, but I am consistently seeing this on a failing CI build.

Expected behavior

Clear error message instead of NPE.

Minimal Complete Reproducible example

N/A

Activity

  1. vorburger commented on Nov 8, 2025

    @vorburger
    ContributorAuthor

    FTR: I'm still seeing this NPE after upgrading from 0.14.1 to 0.15.0. I'll try to debug it using #607. @tzolov

  2. vorburger commented on Nov 8, 2025

    @vorburger
    ContributorAuthor

    Running my enola-dev/enola#1862 with #607 I get:

    java.lang.IllegalStateException: Failed to unmarshal response: JSONRPCResponse[jsonrpc=2.0, id=4937ec33-1, result=null, error=null]
            at io.modelcontextprotocol.spec.McpClientSession.lambda$sendRequest$12(McpClientSession.java:293)
    

    So it look like there appear to be some cases when that jsonRpcResponse is not itself null, but has neither a result nor an error, which I guess is surprising? Perhaps that should be caught earlier?

  3. vorburger commented on Nov 8, 2025

    @vorburger
    ContributorAuthor

    So it look like there appear to be some cases when that jsonRpcResponse is not itself null, but has neither a result nor an error, which I guess is surprising? Perhaps that should be caught earlier?

    In my case, this happened because I used my own custom Jackson ObjectMapper.

    enola-dev/enola#1904 works around this in my project ("downstream"). But it would probably be good if this library wouldn't just throw a confusing internal NPE, but would catch this problem more clearly and earlier. I'll see if I contribute to that.

  4. added a commit that references this issue on Nov 9, 2025
    c5cbc22
  5. vorburger commented on Nov 9, 2025

    @vorburger
    ContributorAuthor

    It would probably be good if this library wouldn't just throw a confusing internal NPE, but would catch this problem more clearly and earlier. I'll see if I contribute to that.

    #658 proposed for this.

  6. added
    bugSomething isn't working
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Feb 20, 2026
  7. added theissue type on Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions