Skip to content

Fix: Missing default connection config propagation#1179

Open
ben-fornefeld wants to merge 6 commits intomainfrom
fix/default-config-propagation
Open

Fix: Missing default connection config propagation#1179
ben-fornefeld wants to merge 6 commits intomainfrom
fix/default-config-propagation

Conversation

@ben-fornefeld
Copy link
Member

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

Note

Low Risk
Small, targeted change to request option wiring; behavior is now more consistent and covered by new regression tests, with minimal risk beyond potential differences for callers relying on missing defaults.

Overview
Fixes missing propagation of a sandbox instance’s default connection config (API key/domain/timeout/headers) when calling instance methods like connect() and pause().

In the JS SDK, multiple sandbox instance methods now consistently merge connectionConfig with per-call overrides via a new resolveApiOpts helper, and new vitest coverage asserts correct forwarding and override behavior. In the Python SDK (sync + async), connect() and pause() now forward params through connection_config.get_api_params(**opts), with new tests validating base params and override/header merging.

Written by Cursor Bugbot for commit 3284d34. 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

changeset-bot bot commented Mar 6, 2026

🦋 Changeset detected

Latest commit: 3284d34

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
Contributor

github-actions bot commented Mar 6, 2026

Package Artifacts

Built from be2c748. Download artifacts from this workflow run.

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

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

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

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

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

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

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.

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 ?? {}),

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
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),

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

)
}

private resolveApiOpts<T extends object>(opts?: T): ConnectionOpts & T {
Copy link
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
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

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

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

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