Add image for Sandbox creation#147
Conversation
Allow setting a VCR image name and optional tag/commit as the source of a new Sandbox.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
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
imagefield and send it on the wire. - Add local validation enforcing mutual exclusivity between
runtimeandimage, 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.
| ] | ||
| ) | ||
| if isinstance(self.source, SnapshotSource) and ( | ||
| self.runtime is not None or self.image is not None |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
| sandbox = Sandbox.create( | ||
| token="test_token", | ||
| team_id="team_test123", | ||
| project_id="prj_test123", | ||
| image="acme/worker:latest", |
Allow setting a VCR image name and optional tag/commit as the source of a new Sandbox.
See vercel/sandbox#232