-
Notifications
You must be signed in to change notification settings - Fork 219
Support envd proxying via header as well as host #1448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| t.Fatalf("ParseHost(%q) error type = %T, want %T", tt.host, err, tt.wantErr) | ||
| } | ||
| if tt.wantErrAs != nil { | ||
| require.ErrorAs(t, err, &tt.wantErrIs) // nolint:testifylint // doesn't need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Error Type Mismatch in Test Validation
The require.ErrorAs call incorrectly uses &tt.wantErrIs instead of &tt.wantErrAs. This causes the test to check the wrong expected error type when wantErrAs is set, making the test validate against an uninitialized or incorrect error value rather than the intended error type.
packages/shared/pkg/proxy/host.go
Outdated
| } | ||
|
|
||
| const ( | ||
| headerSandboxID = "X-Sandbox-Id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recheck the standard.
ValentaTomas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left comments, but lgtm otherwise.
This requires [infra#1448](e2b-dev/infra#1448) first. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds support to override the sandbox API URL (E2B_SANDBOX_URL) across JS/Python SDKs, centralizes sandbox host/url logic with headers, and updates CI to build the SDK before CLI. > > - **SDKs (JS & Python)** > - Add `sandboxUrl` support in `ConnectionConfig` (env var `E2B_SANDBOX_URL`), with new helpers `getSandboxUrl`/`getHost` and shared `envdPort`. > - Refactor sandbox initialization to use `ConnectionConfig.getSandboxUrl(...)` and `getHost(...)`. > - Always attach sandbox headers `E2b-Sandbox-Id` and `E2b-Sandbox-Port` to sandbox and connect requests. > - Python: thread `sandbox_url` through opts; update async/sync connect calls to pass headers; minor fix to default `headers=None` in `e2b_connect.client.Client` stream prep. > - **CI** > - Build `packages/js-sdk` before `packages/cli`; set step `working-directory` for build/test. > - **Dependencies** > - Point `e2b` dependency in lockfile to local `../js-sdk` link. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 5dc5817. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Mish <[email protected]>
This is here to support local dev, but might be useful in production as well?
Note
Enable header-based sandbox routing in proxies and centralize/refine proxy errors; update handlers/tests and tweak orchestrator error message.
packages/shared/pkg/proxy):GetTargetFromRequest(processHeaders)to parse sandbox target from headers (E2b-Sandbox-Id,E2b-Sandbox-Port) or fallback to host viaparseHost.ErrInvalidHost,InvalidSandboxPortError(with port),MissingHeaderError; moveSandboxNotFoundErrorintoerrors.go.TestGetTargetFromRequest, covering header and host cases.packages/client-proxy/internal/proxy/proxy.go): UseGetTargetFromRequest(env.IsLocal())for destination resolution.packages/orchestrator/internal/proxy/proxy.go): Same header-aware target resolution.Written by Cursor Bugbot for commit 1dda59d. This will update automatically on new commits. Configure here.