| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Per the SSE specification (WHATWG HTML Living Standard 9.2.6), an event with no explicit event field MUST be dispatched as a message event. HttpClientStreamableHttpTransport previously used strict equality and silently dropped such frames in the reconnect/GET stream path, causing server-initiated notifications to never reach the handler. Extract classification into a package-private isMessageEvent helper and cover with parameterized unit tests. Closes modelcontextprotocolgh-885
There was a problem hiding this comment.
Thank you for your contribution!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fix HttpClientStreamableHttpTransport silently dropping SSE frames that omit the event: field, in violation of the SSE specification.
Motivation and Context
Per the SSE specification (WHATWG HTML Living Standard §9.2.6):
The current reconnect() / GET SSE stream path in HttpClientStreamableHttpTransport uses a strict equality check:
When a server emits a bare data: frame without an accompanying event: line (which is valid per the spec), event() is null and the frame is silently dropped. This manifests as server-initiated notifications never reaching the handler after initialization completes.
Note the asymmetry: the sendMessage() POST path does not check the event type at all and is unaffected, which is why initialize() succeeds on HttpClient. The bug only impacts server-pushed messages on the open GET stream.
Originally reported in #885 against the Spring WebClientStreamableHttpTransport variant, which was moved to Spring AI 2.0 in #805. This PR fixes the HttpClient variant that remains in this repository.
How Has This Been Tested?
Added HttpClientStreamableHttpTransportSseEventTypeTest with parameterized unit tests covering:
Verified locally:
Breaking Changes
None. This is a pure bug fix that relaxes an overly strict check to match the SSE specification. Existing behavior for explicit "message" events is preserved, and non-message events are still ignored.
Types of changes
Checklist
Additional context
Implementation note: I extracted the classification into a package-private static helper isMessageEvent(String) rather than inlining the null/empty check. This keeps the call site readable, documents the spec rule in one place (with a link to WHATWG §9.2.6 in the Javadoc), and enables direct unit testing without setting up an HTTP server.
Scope: This PR only addresses the HttpClient variant in this repository. The WebClient variant mentioned in #885 lives in Spring AI 2.0 after #805 and would need a separate fix there. See my comment on #885 for details on the asymmetry between the POST and GET paths.
Closes gh-885