Skip to content

feat(sdk): add name filter to snapshot list#1523

Open
mishushakov wants to merge 7 commits into
mainfrom
yokohama
Open

feat(sdk): add name filter to snapshot list#1523
mishushakov wants to merge 7 commits into
mainfrom
yokohama

Conversation

@mishushakov

@mishushakov mishushakov commented Jul 3, 2026

Copy link
Copy Markdown
Member

Adds an optional name filter to Sandbox.listSnapshots() / Sandbox.list_snapshots(), mirroring the infra snapshots list endpoint (e2b-dev/infra#3184). The filter accepts a snapshot name or ID, optionally tag-qualified (e.g. "my-snapshot", "my-team/my-snapshot" or "my-snapshot:v1"); unknown names return an empty list. It's a flat top-level option alongside the existing sandboxId filter (non-breaking) and can be combined with it — the backend applies both with AND, matching the metadata+state behavior of Sandbox.list(). Applied equivalently across the OpenAPI spec, generated clients, and the JS + Python sync/async SDKs, with tests and a changeset.

Usage

// JS/TS
const paginator = Sandbox.listSnapshots({ name: 'my-snapshot' })
const snapshots = await paginator.nextItems()

// combine filters (snapshots from a sandbox matching a name)
Sandbox.listSnapshots({ sandboxId: 'sandbox-id', name: 'my-snapshot' })
# Python (sync)
paginator = Sandbox.list_snapshots(name="my-snapshot")
snapshots = paginator.next_items()

# Python (async)
paginator = AsyncSandbox.list_snapshots(name="my-snapshot")
snapshots = await paginator.next_items()

🤖 Generated with Claude Code

Add an optional `name` filter to `Sandbox.listSnapshots()` /
`Sandbox.list_snapshots()`, mirroring the infra snapshots list endpoint
(e2b-dev/infra#3184). The filter accepts a snapshot name or ID, optionally
tag-qualified (e.g. "my-snapshot", "my-team/my-snapshot" or "my-snapshot:v1");
unknown names return an empty list.

Applied equivalently across the spec, JS SDK, and Python sync + async SDKs,
with tests and a changeset.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7b4420e

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

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

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

@cla-bot cla-bot Bot added the cla-signed label Jul 3, 2026
@cursor

cursor Bot commented Jul 3, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive, backward-compatible API and SDK surface; behavior depends on the already-deployed infra snapshots list endpoint.

Overview
Adds an optional name filter to snapshot listing so callers can target a snapshot by name or ID (including tag- or team-qualified forms like my-team/my-snapshot:v1), with unknown names returning an empty page instead of an error.

The GET /snapshots OpenAPI spec and generated clients gain a name query param; JS exposes it on SnapshotListOpts / SnapshotPaginator, and Python sync/async list_snapshots and paginators pass it through alongside the existing sandboxId / sandbox_id filter (both apply with AND). Integration tests cover match vs no-match; a changeset marks minor releases for e2b and @e2b/python-sdk.

Reviewed by Cursor Bugbot for commit 7b4420e. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Package Artifacts

Built from b6eb227. Download artifacts from this workflow run.

JS SDK (e2b@2.31.1-yokohama.0):

npm install ./e2b-2.31.1-yokohama.0.tgz

CLI (@e2b/cli@2.13.1-yokohama.0):

npm install ./e2b-cli-2.13.1-yokohama.0.tgz

Python SDK (e2b==2.30.0+yokohama):

pip install ./e2b-2.30.0+yokohama-py3-none-any.whl

Align Sandbox.listSnapshots() / Sandbox.list_snapshots() with Sandbox.list():
snapshot filters (sandboxId + the new name filter) now live inside a `query`
object (JS) / SnapshotQuery (Python) instead of flat top-level params.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mishushakov mishushakov changed the title feat(sdk): add name filter to snapshot list feat(sdk): add name filter to snapshot list via query object Jul 3, 2026
mishushakov and others added 2 commits July 3, 2026 13:56
Snapshots can be filtered by source sandbox ID or by name, but not both at
once. JS enforces this via a discriminated union on the query object; Python
raises ValueError in SnapshotQuery when both are set. The instance
list_snapshots() filters by its own sandbox id only (no name).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Moving the released `sandboxId` snapshot filter into a query object was a
breaking change, so revert to flat top-level `sandboxId` / `name` options.
Mutual exclusivity is kept via a runtime guard (JS throws, Python raises
ValueError) instead of a query type, dropping the `never` union and the
SnapshotQuery dataclass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mishushakov mishushakov changed the title feat(sdk): add name filter to snapshot list via query object feat(sdk): add name filter to snapshot list Jul 3, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1c65bc2. Configure here.

Comment thread packages/js-sdk/src/sandbox/sandboxApi.ts Outdated
The backend combines the /snapshots `sandboxID` and `name` query params with
AND, so drop the client-side mutual-exclusivity guard and let both filters be
used together, mirroring the API (and the metadata+state combination in
Sandbox.list).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mishushakov mishushakov marked this pull request as ready for review July 3, 2026 12:30
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Run `make codegen` so the generated JS schema and Python client match the
spec. Move the `name` param description under `schema` (matching `sandboxID`)
so it surfaces in the generated Python docstring.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment thread packages/python-sdk/e2b/sandbox_sync/main.py
…ible

`list_snapshots` is already released with `(limit, next_token)` positional
params. Append the new `name` filter after them (instead of before) so a
positional call like `list_snapshots(50)` still binds `limit`, avoiding a
silent breaking change. Addresses PR review feedback.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant