Skip to content

Add image for Sandbox creation#147

Merged
scotttrinh merged 2 commits into
mainfrom
sandbox-image
Jun 29, 2026
Merged

Add image for Sandbox creation#147
scotttrinh merged 2 commits into
mainfrom
sandbox-image

Conversation

@scotttrinh

Copy link
Copy Markdown
Collaborator

Allow setting a VCR image name and optional tag/commit as the source of a new Sandbox.

See vercel/sandbox#232

Allow setting a VCR image name and optional tag/commit as the source of
a new Sandbox.
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
vercel-py Ready Ready Preview Jun 29, 2026 12:21pm

Request Review

Copilot AI 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.

Pull request overview

Adds support for creating Sandboxes from a Vercel Container Registry (VCR) image, as an alternative to selecting a runtime, with validation to prevent invalid combinations (e.g., runtime + image, or snapshot source + runtime/image).

Changes:

  • Extend sandbox creation request/model plumbing to accept an image field and send it on the wire.
  • Add local validation enforcing mutual exclusivity between runtime and image, and disallowing both when the source is a snapshot.
  • Add unit and integration tests covering serialization and sync/async create flows with image.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit/test_sandbox_create_validation.py Adds unit tests for image serialization and boot-selector validation errors.
tests/integration/test_sandbox_sync_async.py Adds integration tests ensuring image is sent and runtime omitted for sync/async creates.
src/vercel/sandbox/sandbox.py Adds image parameter (and overloads) to Sandbox.create / AsyncSandbox.create, and threads it into the client call.
src/vercel/_internal/sandbox/models.py Adds image to CreateSandboxRequest and enforces runtime/image/snapshot validation rules.
src/vercel/_internal/sandbox/core.py Threads image through create_sandbox request building and serialization.

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

Comment thread src/vercel/_internal/sandbox/models.py Outdated
]
)
if isinstance(self.source, SnapshotSource) and (
self.runtime is not None or self.image is not None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit: we support snapshot + image for now due to an edge case related to WORKDIR (I want to also remove it as both of them should be mutually exclusive), but for now we can't.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Copilot AI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment on lines +117 to +121
sandbox = Sandbox.create(
token="test_token",
team_id="team_test123",
project_id="prj_test123",
image="acme/worker:latest",

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

LGTM, thanks!

@scotttrinh scotttrinh merged commit 0c63924 into main Jun 29, 2026
14 checks passed
@scotttrinh scotttrinh deleted the sandbox-image branch June 29, 2026 13:23
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.

3 participants