sdk: allow envs when connecting to a sandbox#1297
sdk: allow envs when connecting to a sandbox#1297FisherXZ wants to merge 4 commits intoe2b-dev:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 50d8641 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b40c88522e
ℹ️ 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".
| def connect( | ||
| sandbox_id: str, | ||
| timeout: Optional[int] = None, | ||
| envs: Optional[Dict[str, str]] = None, |
There was a problem hiding this comment.
Handle envs in sync class connect path
Adding envs to Sandbox.connect(sandbox_id, ...) exposes a runtime failure for class-style calls: when users call Sandbox.connect("...", envs={...}), the decorator routes to _cls_connect_sandbox, which does not declare envs, so envs stays inside opts and is later expanded into ConnectionConfig(..., **opts), raising TypeError for unexpected keyword envs. This makes the newly documented sync classmethod envs option unusable.
Useful? React with 👍 / 👎.
| async def connect( | ||
| sandbox_id: str, | ||
| timeout: Optional[int] = None, | ||
| envs: Optional[Dict[str, str]] = None, |
There was a problem hiding this comment.
Handle envs in async class connect path
The async class-style API has the same regression: AsyncSandbox.connect("...", envs={...}) routes through _cls_connect_sandbox, which doesn't accept envs, so envs remains in opts and is passed to ConnectionConfig(..., **opts), causing TypeError: unexpected keyword argument 'envs'. As a result, the newly added async classmethod envs parameter fails at runtime.
Useful? React with 👍 / 👎.
Extends POST /sandboxes/{sandboxID}/connect to accept optional
environment variables. Field is optional, wire name envVars matches
create-time sandbox env convention.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds optional envs parameter to Sandbox.connect() in JS and Python SDKs. Maps to envVars on the wire, matching create-time convention. Uses UNSET (not None) in Python so the field is omitted when not supplied. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Matches the create-time pattern (envVars: opts?.envs) — openapi-fetch strips undefined automatically so the conditional spread was unnecessary. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sandbox.connect(sandbox_id, envs=...) routed through _cls_connect_sandbox, which lacked an explicit envs param. envs fell into **opts and was later passed to ConnectionConfig(**opts), raising TypeError on the class-call path. Added envs as an explicit param to both sync and async _cls_connect_sandbox so it is forwarded to _cls_connect and kept out of the opts spread into ConnectionConfig. Added regression tests covering the class-call path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f293a7e to
50d8641
Compare
Summary
Closes #1279.
Extends
POST /sandboxes/{sandboxID}/connectto accept optional environment variables, and wires them through the JS and Python SDKs.envVarsfield toConnectSandboxinspec/openapi.yml; regeneratedschema.gen.tsandconnect_sandbox.pyenvs?: Record<string, string>toSandboxConnectOpts; serialized asenvVars: opts?.envsin the POST body (matches create-time convention)envs: Optional[Dict[str, str]] = Noneto all threeconnect()overloads (sync + async) and both_cls_connectimplementations; passed asenv_vars=envs if envs is not None else UNSETso the field is absent from the wire payload when not suppliedNaming convention (consistent with create-time sandbox envs)
envsenvVarsenv_varsUsage
Test plan
pnpm run typecheckpasses inpackages/js-sdkpnpm run lintpasses inpackages/js-sdkconfigPropagation.test.ts— verifyenvsis forwarded when provided and absent when nottests/sync/sandbox_sync/test_config_propagation.pyandtests/async/sandbox_async/test_config_propagation.py— verifyenv_varspropagation using monkeypatchconnect.test.tsandtest_connect.pycover the no-envs path🤖 Generated with Claude Code