Skip to content

fix(ee): follow HTTP→HTTPS redirects in forward_to_control_plane#8360

Merged
nmgarza5 merged 3 commits intomainfrom
nikg/proxy-follow-redirects
Feb 12, 2026
Merged

fix(ee): follow HTTP→HTTPS redirects in forward_to_control_plane#8360
nmgarza5 merged 3 commits intomainfrom
nikg/proxy-follow-redirects

Conversation

@nmgarza5
Copy link
Copy Markdown
Contributor

@nmgarza5 nmgarza5 commented Feb 11, 2026

Description

forward_to_control_plane in proxy.py and _make_billing_request in service.py both use httpx.AsyncClient which does not follow redirects by default (unlike requests). The control plane's nginx returns a 308 HTTP→HTTPS permanent redirect, causing these requests to fail with "Control plane request failed". Adding follow_redirects=True to both fixes this.

Why this only affects production

Locally, the control plane runs directly on http://localhost with no nginx in front, so there is no HTTP→HTTPS redirect. In production, nginx sits in front of the control plane and forces http://https://, producing the 308 that httpx refuses to follow. Every other code path that talks to the control plane uses the requests library, which follows redirects by default — forward_to_control_plane and _make_billing_request are the only ones using httpx.

How Has This Been Tested?

Unit tests added for both proxy.py and service.py verifying AsyncClient is constructed with follow_redirects=True. Needs deployment to cloud DP to verify end-to-end.

Additional Options

  • [Required] I have considered whether this PR needs to be cherry-picked to the latest beta branch.
  • [Optional] Override Linear Check

@nmgarza5 nmgarza5 requested a review from a team as a code owner February 11, 2026 23:43
@nmgarza5 nmgarza5 changed the title fix: follow redirects in proxy forward_to_control_plane fix(proxy): follow HTTP→HTTPS redirects in forward_to_control_plane Feb 11, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 11, 2026

Greptile Overview

Greptile Summary

Fixes proxy requests failing when control plane sits behind nginx with HTTP→HTTPS redirect. httpx.AsyncClient doesn't follow redirects by default (unlike requests), so control plane's 308 redirect caused all proxy requests to fail with "Control plane request failed". Adding follow_redirects=True resolves this.

  • Added follow_redirects=True parameter to httpx.AsyncClient in forward_to_control_plane
  • Added unit test verifying the client is constructed with the flag enabled
  • No breaking changes, purely additive fix

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Simple one-parameter fix to enable redirect following in httpx client. The change is well-understood (httpx defaults differ from requests library), properly tested with a unit test, and matches the documented behavior of httpx. No logic changes, no security implications.
  • No files require special attention

Important Files Changed

Filename Overview
backend/ee/onyx/server/tenants/proxy.py Added follow_redirects=True to httpx.AsyncClient to handle control plane HTTP→HTTPS redirects
backend/tests/unit/ee/onyx/server/tenants/test_proxy.py Added unit test verifying AsyncClient is instantiated with follow_redirects=True

Sequence Diagram

sequenceDiagram
    participant SH as Self-Hosted Instance
    participant DP as Cloud Data Plane<br/>(proxy.py)
    participant NG as Nginx<br/>(HTTP→HTTPS)
    participant CP as Control Plane

    SH->>DP: POST /proxy/create-checkout-session<br/>(with license Bearer token)
    DP->>DP: Verify license signature
    DP->>NG: POST http://control.example.com/create-checkout-session<br/>(with JWT token)
    Note over NG: Returns 308 Permanent Redirect<br/>Location: https://control.example.com/...
    NG-->>DP: 308 Redirect
    Note over DP: httpx.AsyncClient with<br/>follow_redirects=True
    DP->>CP: POST https://control.example.com/create-checkout-session<br/>(follows redirect automatically)
    CP-->>DP: 200 OK {url: "stripe.com/..."}
    DP-->>SH: 200 OK {url: "stripe.com/..."}
Loading

httpx does not follow redirects by default (unlike requests).
The control plane's nginx returns a 308 HTTP→HTTPS redirect,
which caused proxy requests to fail with "Control plane request
failed" instead of following the redirect transparently.
@nmgarza5 nmgarza5 force-pushed the nikg/proxy-follow-redirects branch from 1718858 to 0562626 Compare February 11, 2026 23:49
@nmgarza5 nmgarza5 changed the title fix(proxy): follow HTTP→HTTPS redirects in forward_to_control_plane fix(ee): follow HTTP→HTTPS redirects in forward_to_control_plane Feb 11, 2026
Copy link
Copy Markdown
Contributor

@justin-tahara justin-tahara left a comment

Choose a reason for hiding this comment

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

Glad it was something simple

Same issue as proxy.py — httpx does not follow redirects by default
(unlike requests), causing 308 failures when the control plane nginx
redirects HTTP→HTTPS.
@nmgarza5 nmgarza5 enabled auto-merge February 11, 2026 23:59
@nmgarza5 nmgarza5 added this pull request to the merge queue Feb 12, 2026
Merged via the queue into main with commit 3ce58c8 Feb 12, 2026
78 of 79 checks passed
@nmgarza5 nmgarza5 deleted the nikg/proxy-follow-redirects branch February 12, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants