| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Replace `response.raise_for_status()` with explicit status code handling that sends a JSONRPCError back through the read stream when the server returns a 4xx/5xx response. This prevents the client from raising an unhandled httpx.HTTPStatusError that would cause pending requests to hang indefinitely. This is a follow-up to #2005 which fixed similar issues for unexpected content types, JSON parse failures, and SSE parse failures but did not address plain HTTP error responses.
|
I'm so good at summarizing PRs nowadays. |
Sorry, something went wrong.
Add test for the case where a notification receives an HTTP error response, covering the branch where `isinstance(message, JSONRPCRequest)` is False in the `>= 400` handler. This fixes the coverage gap that caused CI to fail with 99.99% < 100%.
Add pragma: no branch to async with ClientSession in notification error test — the exception exit branch of the context manager is never taken and coverage.py reports it differently across Python versions.
|
When will it be released to PyPI? |
Sorry, something went wrong.
|
Why is this not implemented in the latest version of this package |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
When a server returns a non-2xx HTTP status code (e.g. 500 Internal Server Error, 403 Forbidden), the streamable HTTP client previously called response.raise_for_status(), which raised an unhandled httpx.HTTPStatusError. This exception was never caught, so the pending request would hang indefinitely — the caller's await session.list_tools() (or similar) would never resolve.
This PR replaces raise_for_status() with explicit status code handling that sends a JSONRPCError back through the read stream, matching the pattern already established for 404 (session terminated) responses. For requests (messages with an id), the client now sends an INTERNAL_ERROR JSONRPCError so the pending request resolves immediately with an MCPError. For notifications (no id), the error is silently discarded since there is no caller waiting for a response.
Follow-up to
Related issues
Related PRs
Test plan