Skip to content

feat(server): expose snapshot restore image reference (imageUri) in the Snapshot API#995

Open
ferponse wants to merge 2 commits into
opensandbox-group:mainfrom
ferponse:feat/snapshot-image-uri
Open

feat(server): expose snapshot restore image reference (imageUri) in the Snapshot API#995
ferponse wants to merge 2 commits into
opensandbox-group:mainfrom
ferponse:feat/snapshot-image-uri

Conversation

@ferponse
Copy link
Copy Markdown

@ferponse ferponse commented Jun 7, 2026

What

Expose the snapshot's restore image reference as imageUri in the Snapshot API model. It is populated once the snapshot reaches Ready, sourced from the value the server already stores in SnapshotRecord.restore_config.image.

Implements #994.

Why

Today the Snapshot responses (POST /sandboxes/{id}/snapshots, GET /snapshots/{id}, GET /snapshots) do not return the resulting OCI image reference. The server computes and stores it, but only uses it internally to resolve same-server snapshotId restores. Since the snapshot store is per-server, restoring a snapshot on a different server or runtime requires the raw image ref via the create-from-image path — which clients currently cannot obtain from the API.

This blocks cross-server / cross-runtime restore (e.g. moving a sandbox between a local Docker-runtime server and a Kubernetes/batchsandbox server through a shared registry).

Change

  • server/opensandbox_server/api/schema.py: add optional image_uri (alias imageUri) to Snapshot.
  • server/opensandbox_server/services/snapshot_service.py: populate it in _to_snapshot_response from record.restore_config.image.

Additive and backward-compatible: the field is Optional and omitted while the snapshot is not Ready (the endpoints already use response_model_exclude_none=True).

Verification

Built the server image from this branch and ran it with runtime=docker:

  1. Created a sandbox and took a snapshot.
  2. GET /snapshots/{id} while Creating → no imageUri (omitted).
  3. Once Ready"imageUri": "opensandbox-snapshots:<id>", matching the committed docker image.

The same _to_snapshot_response mapping serves the Kubernetes runtime, where restore_config.image is the registry ref pushed by the commit Job (SandboxSnapshot.status.containers[].imageUri).

…he Snapshot API

The Snapshot REST response (POST /sandboxes/{id}/snapshots, GET /snapshots/{id},
GET /snapshots) did not include the resulting OCI image reference, although the
server already stores it in SnapshotRecord.restore_config.image. Expose it as
'imageUri' (populated once Ready) so a snapshot can be restored on a different
server/runtime via the create-from-image path -- snapshotId restore is limited
to the originating server's snapshot store. See opensandbox-group#994.

Co-authored-by: Atenea Agent <srv_atenea_gitlab@ofidona.net>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 7, 2026

⚠️ This PR has no labels. Please add one based on the changes.

Changed directories: server.

📋 Recommended labels (based on changed files):

  • component/server ⬅️

Other available labels:

  • bug - Something isn't working
  • dependencies - Pull requests that update a dependency file
  • documentation - Improvements or additions to documentation
  • feature - New feature or request
  • packages - Changes for package, image and configuration

💡 Tip: Use feature for new functionality or improvements, bug for fixes.

cc @ferponse

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: 6955ecbbef

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

Comment on lines +621 to +624
image_uri: Optional[str] = Field(
None,
alias="imageUri",
description=(
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 Add imageUri to the public Snapshot contract

This exposes imageUri in the server response model, but the lifecycle API spec remains the public source of truth and its Snapshot schema still omits this property while declaring additionalProperties: false (specs/sandbox-lifecycle.yml lines 890-920). Clients and SDKs generated from that spec will not discover or model the new restore image field, so the cross-server restore workflow this change enables is still unavailable through the documented contract; please update the spec and regenerate affected outputs.

Useful? React with 👍 / 👎.

Service-level: get_snapshot exposes restore_config.image as image_uri once
Ready; absent while Creating. Route-level: GET /v1/snapshots/{id} serializes
the camelCase imageUri alias and omits it when None.

Co-authored-by: Atenea Agent <srv_atenea_gitlab@ofidona.net>
ferponse pushed a commit to ferponse/OpenSandbox that referenced this pull request Jun 7, 2026
…gate to clients

Addresses the Codex review on opensandbox-group#995: the lifecycle spec is the public source of
truth and declared additionalProperties:false without imageUri, so generated
SDKs would not model the new restore-image field.

- specs/sandbox-lifecycle.yml: add optional imageUri to the Snapshot schema.
- python SDK: regenerate the lifecycle client (snapshot.py) from the spec.
- go SDK: add ImageURI to the hand-written SnapshotInfo (json imageUri).

kotlin and csharp regenerate their lifecycle clients from the spec at build
time; the javascript committed openapi-typescript client needs 'npm run
generate' (toolchains not available in this environment).

Co-authored-by: Atenea Agent <srv_atenea_gitlab@ofidona.net>
@ferponse ferponse force-pushed the feat/snapshot-image-uri branch from 0de66a7 to a8f173b Compare June 7, 2026 01:49
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: 0de66a79a1

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

status: SnapshotStatus
created_at: datetime.datetime
name: str | Unset = UNSET
image_uri: str | Unset = UNSET
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 imageUri into public SDK models

When SDK users call get_snapshot/create_snapshot for a Ready snapshot, this generated wire field is still dropped before it reaches the public SDK objects: the Python converter builds SnapshotInfo without image_uri (sdks/sandbox/python/src/opensandbox/adapters/converter/sandbox_model_converter.py lines 502-513) and the public Python/Kotlin/C# SnapshotInfo models do not expose the property. That leaves most documented SDK clients unable to obtain the restore image this API field is meant to provide, even though the server and spec now return it; please propagate it through the handwritten SDK models/converters as well.

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.

1 participant