Repository navigation
Deflake the initialize dial-error proxy test - #6264
Merged
Merged
Conversation
TestRoundTripDoesNotReplayInitializeOnDialError failed intermittently in a full-suite run with "Received unexpected error" on the HTTP call, while passing every time in isolation. It used http.DefaultClient, whose shared transport pools keep-alive connections across this package's parallel tests. Reusing one whose proxy has since been closed surfaces as a transport error before the request is made. Use a dedicated client with keep-alives disabled. The HTTP outcome is also not what the test asserts. For a dial failure either result is legitimate -- the reverse proxy may synthesize a 502, or the connection may fail outright -- so requiring NoError pinned an incidental detail. The substantive assertions, that no re-initialize reached the target service and that the session was unpinned, are unchanged and still fail when the production guard is removed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
amirejaz
requested review from
ChrisJBurns,
JAORMX,
blkt,
jhrozek and
rdimitrov
as code owners
August 10, 2026 17:56
ChrisJBurns
approved these changes
Aug 10, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6264 +/- ##
==========================================
- Coverage 72.71% 72.70% -0.01%
==========================================
Files 742 742
Lines 77299 77299
==========================================
- Hits 56209 56204 -5
- Misses 17126 17134 +8
+ Partials 3964 3961 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ChrisJBurns
added a commit
that referenced
this pull request
Nov 26, 2026
httptest.Server.Close calls CloseIdleConnections on http.DefaultTransport, so a parallel test reusing a pooled connection can fail with "CloseIdleConnections called". The new upstream validation tests close many servers in parallel, which made this hit TestPrefixHandlers_WellKnownNamespaceCoexistence in CI. Give that test a dedicated client and the validation tests a dedicated backend transport, as #6264 did for the dial-error test. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
ChrisJBurns
added a commit
that referenced
this pull request
Nov 26, 2026
* Validate upstream JSON-RPC responses in proxy The transparent proxy forwarded whatever a backend returned, so a broken backend's malformed answer to a JSON-RPC request reached the client as a successful 200. It now checks the 200 application/json answer to every id-bearing POST before acting on it, and replaces an invalid one with a 502 carrying a JSON-RPC error that echoes the client's request id. The check runs in tracingTransport.RoundTrip, before the response can register a proxy session or mark the server initialized, and reuses the MCP envelope rules through a new mcp.ValidateResponse that inspects the envelope only. The client's Accept-Encoding is withheld from id-bearing requests so Go's transport decodes gzip and the body can be read; a body still carrying a content coding fails closed. Bodies are buffered up to 100 MiB. This reworks the approach from #5288, which validated in ModifyResponse after session registration and rejected some spec-valid responses. Fixes #5247 Co-authored-by: Bishnu Bista <[email protected]> Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> * Isolate proxy tests from the shared transport httptest.Server.Close calls CloseIdleConnections on http.DefaultTransport, so a parallel test reusing a pooled connection can fail with "CloseIdleConnections called". The new upstream validation tests close many servers in parallel, which made this hit TestPrefixHandlers_WellKnownNamespaceCoexistence in CI. Give that test a dedicated client and the validation tests a dedicated backend transport, as #6264 did for the dial-error test. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> --------- Co-authored-by: Bishnu Bista <[email protected]> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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
TestRoundTripDoesNotReplayInitializeOnDialErrorfails intermittently in a full-suite run withReceived unexpected erroron the HTTP call, while passing every time in isolation (6/6 plain, 4/4 with-race).It used
http.DefaultClient, whose shared transport pools keep-alive connections across this package's parallel tests. Reusing one whose proxy has since been closed surfaces as a transport error before the request is even made.DisableKeepAlives.NoErroron the request itself. For a dial failure either outcome is legitimate — the reverse proxy may synthesize a 502, or the connection may fail outright — so that assertion pinned an incidental detail rather than the behaviour under test.Type of change
Test plan
task test)task lint-fix)Package green with
-race, and the test still fails when the production guard it covers is removed:So the relaxed HTTP assertion did not weaken what the test actually guards.
Does this introduce a user-facing change?
No. Test-only.
Special notes for reviewers
Mine from #6152, surfaced in a full-suite run rather than CI. Other tests in this file use
http.DefaultClienttoo and are presumably exposed to the same reuse hazard; I have left them alone rather than widen this beyond the test that actually failed.Generated with Claude Code