fix(gateway): reject uncorrelated HTTP JSON-RPC errors - #689
Merged
Merged
Conversation
jmagar
enabled auto-merge (squash)
September 19, 2026 02:33
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
Reject non-2xx JSON-RPC error responses unless the response id exactly matches the request Labby just sent.
The custom Streamable HTTP adapter previously accepted any non-2xx body that parsed as a JSON-RPC error. A malformed upstream error such as
{"jsonrpc":"2.0","id":null,"error":...}was returned to rmcp as a successful transport response even when the pending request had id1. rmcp could not correlate that response, so the pending request stayed orphaned until Labby's outer Code Mode timeout (~59 s).This was reproduced against ExGPT: an immediate upstream HTTP 500 with
id:nullwas surfaced by Labby as a one-minute timeout.The adapter now captures the outbound JSON-RPC id before sending and only treats a non-success JSON-RPC error as a protocol response when its id exactly matches. Null or mismatched ids fall through to the existing sanitized terminal HTTP transport error path.
Security / correctness properties
Verification
cargo fmt --allcargo test -p labby-gateway --lib non_success_jsonrpc_error --locked→ 3 passedcargo test -p labby-gateway --lib upstream::http_client::tests --locked→ 32 passedgit diff --checkClippy with
-D warningsis currently blocked by pre-existing warnings in untouched labby-gateway/code-mode files (for exampleunused_async_trait_implandresult_large_err); this change introduces no new clippy diagnostic inhttp_client.rs.Related upstream bug
The incident also exposed a separate MCP Elixir SDK bug that emitted
data: :absent, causing its response budget to falsely reportresponse_too_large. That fix is isolated in dinglebear-ai/mcp-elixir-sdk#9. This Labby change remains valuable defensively even after that SDK fix because upstreams must never be allowed to orphan or cross-correlate pending requests with null/wrong ids.