test: add tests for non-2xx HTTP status handling (fixes #3091)
Closed
ZS
3mo ago+133+133+012345678901234567890123456789-0-0-0123456789
Summary
Add tests verifying that StreamableHTTPTransport._handle_post_request properly handles non-2xx HTTP status codes.
Tests Added
- 401 Unauthorized → JSONRPCError with request ID (not timeout)
- 403 Forbidden → JSONRPCError with request ID
- 500 Internal Server Error → JSONRPCError with request ID
- JSON error body → Parsed and used directly
Verification
The current implementation already handles non-2xx correctly (lines 342-373 in streamable_http.py). These tests document the expected behavior and prevent regressions.
Key Behavior
- Non-2xx status →
JSONRPCErrorsent to caller with original request ID - JSON-RPC error body → Parsed and forwarded directly
- Non-JSON body → Fallback to generic
INTERNAL_ERROR
Closes #3091
/claim #3091