Skip to content

fix: pass apiKey from connectionConfig to pause() method#1218

Open
passionworkeer wants to merge 1 commit intoe2b-dev:mainfrom
passionworkeer:fix/pause-apiKey
Open

fix: pass apiKey from connectionConfig to pause() method#1218
passionworkeer wants to merge 1 commit intoe2b-dev:mainfrom
passionworkeer:fix/pause-apiKey

Conversation

@passionworkeer
Copy link

When using Sandbox.connect() with an apiKey, the pause() method was not passing the apiKey to the API call, causing auth failures. This fix ensures pause() (and deprecated betaPause()) use the same pattern as kill() - merging connectionConfig with provided opts.

Fixes: #1215

When using Sandbox.connect() with an apiKey, the pause() method was not
passing the apiKey to the API call, causing auth failures. This fix
ensures pause() (and deprecated betaPause()) use the same pattern as
kill() - merging connectionConfig with provided opts.

Fixes: e2b-dev#1215
Copilot AI review requested due to automatic review settings March 19, 2026 21:34
@changeset-bot
Copy link

changeset-bot bot commented Mar 19, 2026

⚠️ No Changeset found

Latest commit: dd26a14

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@passionworkeer
Copy link
Author

@e2b-dev/copilot Ready for review!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes authentication failures when calling Sandbox.pause() (and deprecated betaPause()) on a sandbox created via Sandbox.connect() with an apiKey, by ensuring the instance’s connectionConfig is merged into the pause call options (matching the existing kill() pattern).

Changes:

  • Update Sandbox.pause() to pass { ...this.connectionConfig, ...opts } into SandboxApi.pause().
  • Update Sandbox.betaPause() to pass { ...this.connectionConfig, ...opts } into SandboxApi.betaPause().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 587 to +588
async pause(opts?: ConnectionOpts): Promise<boolean> {
return await SandboxApi.pause(this.sandboxId, opts)
return await SandboxApi.pause(this.sandboxId, { ...this.connectionConfig, ...opts })
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

The JSDoc for pause() says it returns a sandbox ID that can be used to resume, but the method signature and implementation return Promise<boolean> (matching SandboxApi.pause). Please update the @returns description to reflect the boolean semantics (true=paused, false=already paused).

Copilot uses AI. Check for mistakes.
*/
async pause(opts?: ConnectionOpts): Promise<boolean> {
return await SandboxApi.pause(this.sandboxId, opts)
return await SandboxApi.pause(this.sandboxId, { ...this.connectionConfig, ...opts })
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

This change fixes a regression scenario where Sandbox.connect(id, { apiKey }) should allow calling sandbox.pause() without re-supplying the key (especially when E2B_API_KEY is not set). There are existing integration tests around pause/connect, but none cover this credential-propagation case; please add a regression test that temporarily unsets process.env.E2B_API_KEY, creates/connects using an explicit apiKey, and asserts pause() succeeds.

Copilot uses AI. Check for mistakes.
passionworkeer added a commit to passionworkeer/E2B that referenced this pull request Mar 20, 2026
…tion

- Update @returns JSDoc: pause() returns boolean (true=paused, false=already paused)
  matching SandboxApi.pause semantics, not a sandbox ID
- Add regression tests for apiKey propagation in Sandbox.connect():
  - pause() succeeds when E2B_API_KEY is unset but apiKey is passed to connect()
  - pause() returns false when sandbox is already paused
  - pause() works on connected sandbox with apiKey in connectionConfig

Refs: Copilot PR e2b-dev#1218 review comments
@ValentaTomas ValentaTomas removed their request for review March 21, 2026 06:40
@passionworkeer
Copy link
Author

Hi, checking in - this PR adds apiKey propagation to the pause() method. Copilot reviewed with no issues. Is there anything needed to move forward?

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.

[Bug]: Passed Credential in Sandbox.connect, does not get used in .pause method like in .kill

2 participants