Skip to content

Conversation

@djeebus
Copy link
Contributor

@djeebus djeebus commented Nov 6, 2025

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.

  • Shared Proxy Library (packages/shared/pkg/proxy):
    • Target Resolution: Add GetTargetFromRequest(processHeaders) to parse sandbox target from headers (E2b-Sandbox-Id, E2b-Sandbox-Port) or fallback to host via parseHost.
    • Errors: Introduce ErrInvalidHost, InvalidSandboxPortError (with port), MissingHeaderError; move SandboxNotFoundError into errors.go.
    • Handler: Update error handling to support new errors and improved logging.
    • Tests: Replace host parser tests with TestGetTargetFromRequest, covering header and host cases.
  • Proxies:
    • Client Proxy (packages/client-proxy/internal/proxy/proxy.go): Use GetTargetFromRequest(env.IsLocal()) for destination resolution.
    • Orchestrator Sandbox Proxy (packages/orchestrator/internal/proxy/proxy.go): Same header-aware target resolution.
  • API:
    • Adjust error reporting/messages in sandbox placement path ("failed to place sandbox").

Written by Cursor Bugbot for commit 1dda59d. This will update automatically on new commits. Configure here.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

@djeebus djeebus enabled auto-merge (squash) November 7, 2025 01:10
@djeebus djeebus changed the title Support envd proxying via header, not host Support envd proxying via header as well as host Nov 7, 2025
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
Copy link

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.

Fix in Cursor Fix in Web

}

const (
headerSandboxID = "X-Sandbox-Id"
Copy link
Member

Choose a reason for hiding this comment

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

Recheck the standard.

Copy link
Member

@ValentaTomas ValentaTomas left a 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.

@djeebus djeebus merged commit b18e88d into main Nov 8, 2025
27 checks passed
@djeebus djeebus deleted the support-envd-proxy-via-header branch November 8, 2025 00:42
djeebus added a commit to e2b-dev/E2B that referenced this pull request Nov 14, 2025
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]>
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.

3 participants