Skip to content

fix(client): surface non-2xx POST failures to the awaiting caller (#2110) - #3387

Closed
UgaTheDev wants to merge 1 commit into
modelcontextprotocol:mainfrom
UgaTheDev:fix/http-error-propagation
Closed

fix(client): surface non-2xx POST failures to the awaiting caller (#2110)#3387
UgaTheDev wants to merge 1 commit into
modelcontextprotocol:mainfrom
UgaTheDev:fix/http-error-propagation

Conversation

@UgaTheDev

Copy link
Copy Markdown

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

…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>
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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 Fixes #123 or similar).

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 Fixes #<number> to this PR's description. If a maintainer would like the change as a PR from you, they'll assign you to the issue and this PR will reopen automatically.

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 missing-issue-link label, or adding bypass-issue-check bypasses the check.

@github-actions github-actions Bot closed this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant