Fix deterministic E2E proxy SSE endpoint rewrite tests#4093
Merged
aponcedeleonch merged 1 commit intomainfrom Mar 11, 2026
Merged
Fix deterministic E2E proxy SSE endpoint rewrite tests#4093aponcedeleonch merged 1 commit intomainfrom
aponcedeleonch merged 1 commit intomainfrom
Conversation
These SSE endpoint rewrite tests were orphaned from CI until the matrix rebalance (#4074), then had stale flags fixed (#4080), but have never actually passed. Four root causes are addressed: 1. GenerateMCPServerURL omits /sse for remote SSE URLs with empty path, causing waitForInitializeSuccess to GET / instead of /sse (404). 2. getSSERewriteConfig reads X-Forwarded-* from the outbound request which has auto-injected headers from SetXForwarded(), converting relative endpoint URLs into absolute ones with the proxy's own host. 3. Test 3 mock server lacks a 404 fallback for non-/sse paths. 4. Test 4 (OSV + endpoint-prefix) fails due to #3372; skip it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4093 +/- ##
==========================================
- Coverage 68.52% 68.52% -0.01%
==========================================
Files 447 447
Lines 45679 45691 +12
==========================================
+ Hits 31300 31308 +8
- Misses 11963 11966 +3
- Partials 2416 2417 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jhrozek
approved these changes
Mar 11, 2026
Contributor
jhrozek
left a comment
There was a problem hiding this comment.
there are still some flaky tests but the one that was failing is not anymore
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
The SSE endpoint rewrite E2E tests (
proxy && sse && endpoint-rewrite) fail 100% of the time. They were orphaned from CI until the matrix rebalance (#4074), then had stale flags fixed (#4080), but have never actually passed. This PR fixes four root causes identified through local reproduction and log inspection.GenerateMCPServerURLomits/ssefor remote SSE URLs with no path, sowaitForInitializeSuccesssendsGET /instead ofGET /sse— the mock server returns 404, init retries for 5 min, and the test's 60s timeout expiresgetSSERewriteConfigreadsX-Forwarded-*headers from the outbound request, which has auto-injected values fromSetXForwarded(), converting relative endpoint URLs (/sse?sessionId=...) into absolute URLs with the proxy's own host — breaking test 3's assertionelseclause for non-/ssepaths (Go defaults to 200 OK), inconsistent with tests 1 and 2--endpoint-prefix) fails because the proxy doesn't strip the prefix from incoming requests (Strip endpointPrefix from request paths in transparent proxy #3372); skipped with a reference to the tracking issueType of change
Test plan
task test)task lint-fix)Changes
pkg/transport/url.go/ssepath for remote SSE URLs with empty pathpkg/transport/url_test.go/ssepkg/transport/proxy/transparent/sse_response_processor.gopkg/transport/proxy/transparent/transparent_proxy.goRewritepkg/transport/proxy/transparent/transparent_test.goTestGetSSERewriteConfigto pass inbound request via contexttest/e2e/sse_endpoint_rewrite_test.goSpecial notes for reviewers
The core issue with Bug 3 is subtle:
httputil.ReverseProxy.Rewritecallspr.SetXForwarded()which writesX-Forwarded-Host,X-Forwarded-Proto, etc. ontopr.Out. Then inModifyResponse,resp.Requestispr.Out— sogetSSERewriteConfigwas reading the proxy's own auto-injected headers rather than the client's original headers. The fix stashespr.In(the original inbound request) in the outbound request's context so the response processor can read the real client headers.Test 4 is skipped rather than fixed because the underlying issue (#3372 — endpoint prefix stripping for incoming requests) requires a separate design decision.
Generated with Claude Code