Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
What does this change do and why?
Fix JSON-RPC 2.0 protocol violation: the server was sending a response to every client notification, and
notifications/cancelledwas silently broken on both transports.Root causes:
message_middlewareunconditionally calledsender.send(resp.into())for all message types, includingMessage::Notification. This wrote{"jsonrpc":"2.0","id":"(no id)","result":{}}to the wire for every incoming notification — a direct violation of JSON-RPC 2.0 §4 ("A Notification is a Request objectwithout an 'id' member ... The Server MUST NOT reply to a Notification").
handle_notificationnever dispatchednotifications/cancelledto the cancellation logic. Thenotifications_cancelhandler was registered viamap_handler(therequest handler map), but notifications are routed to
handle_notification, not through that map — socancel_request()was never called.Streamable HTTP
handle_messagereturned202 Acceptedfor notifications without forwarding them to the app at all, so they were silently dropped before reachinghandle_notification.Changes:
handle_notificationnow takesruntime: ServerRuntime, dispatchesnotifications/cancelledtoruntime.options().cancel_request()directly, and returns()insteadof a dummy
Response.handle_messagereturnsOption<Response>— notifications yieldNone, requests and received responses yieldSome(_).message_middlewareonly callssender.send()whenhandle_messagereturnsSome.handle_messageforwards notifications to the app viamanager.senderbefore returning202.map_handlerregistrations and the now-unreachablenotifications_init/notifications_cancelhandler functions.Type
Checklist
Notes for reviewers
The
Message::Responsepath inmessage_middlewareis intentionally left unchanged — when an HTTP client POSTs a response (e.g. answering a server-initiated samplingrequest),
handle_responsereturnsResponse::empty(resp_id)which the HTTP dispatch loop uses to complete the pending oneshot channel and unblock the HTTP handler.Changing that would require reworking the HTTP request/response correlation mechanism and is a separate concern.