Skip to content

Fix: Missing default connection config propagation#1179

Merged
ben-fornefeld merged 9 commits intomainfrom
fix/default-config-propagation
Mar 23, 2026
Merged

Fix: Missing default connection config propagation#1179
ben-fornefeld merged 9 commits intomainfrom
fix/default-config-propagation

Conversation

@ben-fornefeld
Copy link
Copy Markdown
Member

@ben-fornefeld ben-fornefeld commented Mar 6, 2026

Note

Medium Risk
Changes how instance methods merge and forward connection options (api key/domain/headers/timeouts) to API calls in both JS and Python SDKs, which can affect request routing and auth headers. Regression tests reduce risk but behavior changes could impact callers relying on previous (incorrect) defaults.

Overview
Fixes missing propagation of instance connectionConfig when calling sandbox instance methods (notably pause/betaPause/connect, plus related methods) so default config is always forwarded and per-call overrides still win.

In the JS SDK this centralizes option merging via a new resolveApiOpts() helper and updates multiple SandboxApi.* calls to use it; in the Python SDK it updates Sandbox.connect() and Sandbox.pause() (sync + async) to pass self.connection_config.get_api_params(**opts).

Adds regression tests in both SDKs to assert defaults are forwarded and overrides are applied correctly.

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

@ben-fornefeld ben-fornefeld added the bug Something isn't working label Mar 6, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 6, 2026

🦋 Changeset detected

Latest commit: 60aa6ca

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Patch
e2b Patch

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

Package Artifacts

Built from 5b53c24. Download artifacts from this workflow run.

JS SDK (e2b@2.15.1-fix-default-config-propagation.0):

npm install ./e2b-2.15.1-fix-default-config-propagation.0.tgz

CLI (@e2b/cli@2.8.3-fix-default-config-propagation.0):

npm install ./e2b-cli-2.8.3-fix-default-config-propagation.0.tgz

Python SDK (e2b==2.16.0+fix-default-config-propagation):

pip install ./e2b-2.16.0+fix.default.config.propagation-py3-none-any.whl

Comment thread packages/js-sdk/src/sandbox/index.ts
Copy link
Copy Markdown

@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.

Reviewed commit: 90de8fc509

ℹ️ 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".

Comment on lines +818 to +820
return {
...this.connectionConfig,
...opts,
})
...(opts ?? {}),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Drop inherited apiUrl when resolving instance API options

resolveApiOpts now forwards the full stored connectionConfig, which always includes a concrete apiUrl; if a caller overrides only domain on instance calls like connect()/pause(), the inherited apiUrl still takes precedence when ConnectionConfig is rebuilt, so the request is sent to the original API host instead of the override domain. This regression is specific to the newly migrated instance methods and makes per-call domain overrides ineffective unless callers also pass apiUrl explicitly.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is fine

sandbox_id=self.sandbox_id,
timeout=timeout,
**opts,
**self.connection_config.get_api_params(**opts),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid injecting base api_url into instance connect/pause opts

Using self.connection_config.get_api_params(**opts) here injects the stored api_url into every call; when users pass a per-call domain override without api_url, _cls_connect/_cls_pause rebuild ConnectionConfig from kwargs and keep the old api_url, so the override domain is ignored. This is a behavior change from the previous **opts path for these instance methods (and the same pattern is now present in both sync and async implementations).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is fine

Comment thread packages/js-sdk/src/sandbox/index.ts Outdated
)
}

private resolveApiOpts<T extends object>(opts?: T): ConnectionOpts & T {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you can just narrow it down to just extends ConnectionOpts

@mishushakov
Copy link
Copy Markdown
Member

I am not sure this is a safe change, because what if I want to set things like requestTimeout on Sandbox.create but don't want it to be propagated to other class methods? Imo we should only inherit properties like apiUrl/domain, the rest looks fine

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

@ben-fornefeld ben-fornefeld force-pushed the fix/default-config-propagation branch from 17f0fbd to b80f0e5 Compare March 6, 2026 22:40
@dobrac dobrac assigned mishushakov and unassigned dobrac Mar 10, 2026
@e2b-dev e2b-dev deleted a comment from cursor Bot Mar 10, 2026
@ValentaTomas ValentaTomas removed their request for review March 12, 2026 02:19
@mishushakov
Copy link
Copy Markdown
Member

also please fix Sandbox as any, if it's not necessary

@ben-fornefeld ben-fornefeld merged commit 1c55083 into main Mar 23, 2026
23 checks passed
@ben-fornefeld ben-fornefeld deleted the fix/default-config-propagation branch March 23, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants