fix: isolate streamable HTTP POST errors#2613
Open
pragnyanramtha wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Backports main’s request-scoped handling of HTTP POST failures for the Streamable HTTP transport in the v1.x line, preventing a single request’s non-2xx POST response from escaping the per-request task and tearing down concurrent sibling requests.
Changes:
- Convert POST HTTP
>=400(non-404) responses into request-scoped JSON-RPC errors for JSON-RPC requests (and avoid synthesizing responses for notifications). - Add a concurrency regression test ensuring one failing POST does not cancel an unrelated in-flight request.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/mcp/client/streamable_http.py |
Scopes POST HTTP error handling to the originating JSON-RPC request instead of raising through the shared task group. |
tests/shared/test_streamable_http.py |
Adds a regression test covering concurrent requests where one receives an HTTP 400 and the other still completes successfully. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8d17351 to
ab917f9
Compare
ab917f9 to
cca10c2
Compare
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
Fixes #2604.
This targets
v1.xbecause the released 1.x branch still raises throughresponse.raise_for_status()for POST HTTP errors.mainalready has equivalent scoped>=400handling; this PR backports that behavior and adds the concurrency regression coverage for the reported failure mode.Validation
uv run --frozen pytest tests/shared/test_streamable_http.py::test_streamable_http_client_http_error_does_not_cancel_concurrent_requestuv run --frozen pytest tests/shared/test_streamable_http.py-> 52 passeduv run --frozen pytest tests/shared/test_streamable_http.py::test_streamable_http_client_http_error_does_not_cancel_concurrent_request tests/shared/test_streamable_http.py::test_streamable_http_client_session_termination tests/shared/test_streamable_http.py::test_streamable_http_client_session_termination_204 tests/client/test_notification_response.py::test_non_compliant_notification_response-> 4 passeduv run --frozen ruff check src/mcp/client/streamable_http.py tests/shared/test_streamable_http.pyuv sync --frozen --all-extras --devuv run --frozen pyright-> 0 errorsgit diff --check