Skip to content

fix(js-sdk): forward name param in createSnapshot and return names#1263

Open
Yanhu007 wants to merge 1 commit intoe2b-dev:mainfrom
Yanhu007:fix/js-sdk-snapshot-name
Open

fix(js-sdk): forward name param in createSnapshot and return names#1263
Yanhu007 wants to merge 1 commit intoe2b-dev:mainfrom
Yanhu007:fix/js-sdk-snapshot-name

Conversation

@Yanhu007
Copy link
Copy Markdown

Summary

Fixes #1249

createSnapshot() sends body: {}, silently ignoring the name parameter. The SnapshotInfo interface also omits the names array from the API response. This means SDK users cannot create named snapshots.

Changes

sandboxApi.ts

  • CreateSnapshotOpts: new interface extending SandboxApiOpts with optional name
  • SnapshotInfo: added names: string[] field
  • createSnapshot(): forwards name to request body, returns names from response
  • SnapshotPaginator.nextItems(): returns names from list response

index.ts (sandbox)

  • Updated instance createSnapshot() to accept CreateSnapshotOpts

index.ts (package)

  • Exported CreateSnapshotOpts

Before / After

// Before: name silently ignored, names not returned
const snapshot = await sandbox.createSnapshot({ name: 'my-snapshot' })
// snapshot.snapshotId = 'abc123:default'
// snapshot.names = undefined

// After: name forwarded, names returned
const snapshot = await sandbox.createSnapshot({ name: 'my-snapshot' })
// snapshot.snapshotId = 'team/my-snapshot:default'
// snapshot.names = ['team/my-snapshot:default']

createSnapshot() sends an empty body, ignoring the name parameter
from the API. The SnapshotInfo interface also omits the names array
from the API response. This means SDK users cannot create named
snapshots.

- Add CreateSnapshotOpts with optional name field
- Forward name to POST /sandboxes/{sandboxID}/snapshots body
- Add names to SnapshotInfo interface
- Return names from both createSnapshot and list paginator
- Export CreateSnapshotOpts from package index

Fixes e2b-dev#1249
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 12, 2026

⚠️ No Changeset found

Latest commit: 0937011

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

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: 09370119f9

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

},
body: {},
body: {
...(opts?.name && { name: opts.name }),
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 Forward empty snapshot names to API

The request body currently uses a truthy guard (opts?.name && { name: opts.name }), which drops name when it is an empty string. In that case createSnapshot({ name: '' }) is silently converted into an unnamed snapshot request instead of preserving caller intent and letting the API validate/reject the value, which can create unexpected anonymous snapshots when names come from user input. Check explicitly for undefined so every provided value is forwarded.

Useful? React with 👍 / 👎.

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.

JS SDK: createSnapshot does not forward the 'name' parameter to the REST API

1 participant