Skip to content

Add X-Forwarded-Prefix support for SSE endpoint URL rewriting#3210

Merged
amirejaz merged 12 commits intomainfrom
proxy-header
Jan 8, 2026
Merged

Add X-Forwarded-Prefix support for SSE endpoint URL rewriting#3210
amirejaz merged 12 commits intomainfrom
proxy-header

Conversation

@dmjb
Copy link
Copy Markdown
Contributor

@dmjb dmjb commented Jan 7, 2026

[Originally created by @jhrozek]

Implement SSE endpoint URL rewriting in the TransparentProxy to support
path-based ingress routing that strips path prefixes.

Changes:

  • Add endpointPrefix and trustProxyHeaders fields to TransparentProxy
  • Add sseRewriteConfig type for holding rewrite configuration
  • Add getSSERewriteConfig() to determine rewrite config with priority:
    1. Explicit endpointPrefix (highest priority)
    2. X-Forwarded-Prefix header (when trustProxyHeaders is true)
    3. No rewriting (default)
  • Add rewriteEndpointURL() to handle both relative and absolute URLs
  • Refactor SSE response processing with sseLineProcessor struct
  • Only rewrite "event: endpoint" events, pass others unchanged
  • Preserve existing session ID extraction functionality

Fixes #3071

Large PR Justification

  • A significant chunk of the diff relates to testing and docs.

@github-actions github-actions bot added the size/L Large PR: 600-999 lines changed label Jan 7, 2026
@dmjb dmjb changed the title [DRAFT] Proxy header [DRAFT] Rewrite proxy header for SSE workloads Jan 7, 2026
@dmjb dmjb changed the title [DRAFT] Rewrite proxy header for SSE workloads [DRAFT] Add X-Forwarded-Prefix support for SSE endpoint URL rewriting Jan 7, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 74.30556% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 57.06%. Comparing base (4968979) to head (95d4d6f).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...nsport/proxy/transparent/sse_response_processor.go 80.18% 12 Missing and 9 partials ⚠️
pkg/runner/config_builder.go 0.00% 4 Missing ⚠️
pkg/transport/factory.go 0.00% 4 Missing ⚠️
pkg/transport/http.go 0.00% 4 Missing ⚠️
.../transport/proxy/transparent/response_processor.go 83.33% 2 Missing ⚠️
pkg/runner/runner.go 0.00% 1 Missing ⚠️
...g/transport/proxy/transparent/transparent_proxy.go 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3210      +/-   ##
==========================================
+ Coverage   56.99%   57.06%   +0.06%     
==========================================
  Files         348      350       +2     
  Lines       34635    34744     +109     
==========================================
+ Hits        19740    19826      +86     
- Misses      13250    13270      +20     
- Partials     1645     1648       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 7, 2026
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 7, 2026
jhrozek and others added 6 commits January 7, 2026 16:55
Implement SSE endpoint URL rewriting in the TransparentProxy to support
path-based ingress routing that strips path prefixes.

Changes:
- Add endpointPrefix and trustProxyHeaders fields to TransparentProxy
- Add sseRewriteConfig type for holding rewrite configuration
- Add getSSERewriteConfig() to determine rewrite config with priority:
  1. Explicit endpointPrefix (highest priority)
  2. X-Forwarded-Prefix header (when trustProxyHeaders is true)
  3. No rewriting (default)
- Add rewriteEndpointURL() to handle both relative and absolute URLs
- Refactor SSE response processing with sseLineProcessor struct
- Only rewrite "event: endpoint" events, pass others unchanged
- Preserve existing session ID extraction functionality

Fixes #3071

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Wire the endpointPrefix configuration through the transport layer:
- Add EndpointPrefix to transport.Config struct
- Add EndpointPrefix to runner.RunConfig struct
- Update HTTPTransport to accept and pass endpointPrefix to proxy
- Update factory.go to pass EndpointPrefix from config
- Update runner.go to include EndpointPrefix in transport config

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add CLI support for specifying the SSE endpoint URL prefix:
- Add EndpointPrefix field to RunFlags struct
- Add --endpoint-prefix flag with help text
- Add validation to ensure prefix starts with '/' when provided
- Add WithEndpointPrefix builder option in config_builder.go

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Kubernetes CRD support for configuring SSE endpoint URL prefix:
- Add EndpointPrefix field to MCPServerSpec and MCPRemoteProxySpec
- Wire field through controllers to runner config
- Regenerate CRD manifests with operator-generate/operator-manifests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Regenerate CLI docs with new --endpoint-prefix flag
- Add SSE Endpoint URL Rewriting section to transport architecture doc
- Document priority order, CLI usage, and Kubernetes CRD examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions github-actions bot added size/L Large PR: 600-999 lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 7, 2026
@dmjb dmjb changed the title [DRAFT] Add X-Forwarded-Prefix support for SSE endpoint URL rewriting Add X-Forwarded-Prefix support for SSE endpoint URL rewriting Jan 7, 2026
@dmjb dmjb marked this pull request as ready for review January 7, 2026 17:05
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/L Large PR: 600-999 lines changed labels Jan 7, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@github-actions github-actions bot dismissed their stale review January 7, 2026 17:22

Large PR justification has been provided. Thank you!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 7, 2026

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 7, 2026
In order to minimize the amount of transport-specific logic in the
transparent proxy, create a response processor interface and put the new
SSE rewrite logic behind that interface. Create a no-op implementation
for HTTP streamable.
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 7, 2026
amirejaz
amirejaz previously approved these changes Jan 8, 2026
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 8, 2026
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 8, 2026
@amirejaz amirejaz merged commit 8e8af3b into main Jan 8, 2026
36 checks passed
@amirejaz amirejaz deleted the proxy-header branch January 8, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add X-Forwarded-Prefix support for SSE transport (TransparentProxy)

4 participants