fix(client): surface non-2xx POST failures to the awaiting caller (#2110) - #3387
fix(client): surface non-2xx POST failures to the awaiting caller (#2110)#3387UgaTheDev wants to merge 1 commit into
Conversation
…delcontextprotocol#2110) The SSE transport's post_writer caught every exception from the message POST, logged it, and returned. `raise_for_status()` on a 401/403/5xx was therefore swallowed: the request it carried never received a response and its caller waited forever. Fail that request instead, correlated by its own id, so only the caller whose POST was rejected is affected -- a session-wide fan-out would tear down unrelated in-flight requests, and raw `Exception` items on the read stream are also used for non-fatal per-message parse errors. Both transports now also carry the HTTP status on `ErrorData.data`. The JSON-RPC code cannot express it: every non-404 failure maps to INTERNAL_ERROR, which alone cannot tell a caller whether to re-authenticate (401/403) or retry (5xx). Error messages are unchanged. Signed-off-by: Kush Zingade <kushzingade@honorsocietyofcinematicarts.org>
|
Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because its description doesn't yet link an open issue in this repository (with If there isn't an issue for this yet, please open one — a clear description of the problem is genuinely the most useful thing for us. Then add There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten. Maintainers: reopening this PR, removing the |
The SSE transport's post_writer caught every exception from the message
POST, logged it, and returned.
raise_for_status()on a 401/403/5xx wastherefore swallowed: the request it carried never received a response and
its caller waited forever.
Fail that request instead, correlated by its own id, so only the caller
whose POST was rejected is affected -- a session-wide fan-out would tear
down unrelated in-flight requests, and raw
Exceptionitems on the readstream are also used for non-fatal per-message parse errors.
Both transports now also carry the HTTP status on
ErrorData.data. TheJSON-RPC code cannot express it: every non-404 failure maps to
INTERNAL_ERROR, which alone cannot tell a caller whether to
re-authenticate (401/403) or retry (5xx). Error messages are unchanged.
Signed-off-by: Kush Zingade kushzingade@honorsocietyofcinematicarts.org