fix(api): GetSandboxesSandboxID omits VolumeMounts and sets empty string Alias for paused sandboxes
まだ誰も着手していません。
評価
調査の方向性
packages/api/internal/handlers/sandbox_get.go から始め、特に235-265行付近のpaused sandboxのマッピングを確認し、そのVolumeMountsとAliasの処理をsandboxes_list.goと比較してください。orchestratorがnilの場合のガードを追加し、sandbox_get_test.goでpaused snapshotのケースをカバーしてください。paused responseでvolume mountsが保持され、空のaliasが省略され、orchestratorがnilでもpanicしなければ完了です。
索引モデルが issue の本文から書いたものです。
説明
Problem
When querying sandbox metadata via GET /sandboxes/{sandboxID} (packages/api/internal/handlers/sandbox_get.go), paused or stopped sandboxes loaded from lastSnapshot exhibit two payload inconsistencies with the OpenAPI specification and list endpoints:
-
Missing
VolumeMountsin Paused Sandbox Response:
When a sandbox is paused,lastSnapshot.Snapshot.Config.VolumeMountscontains all persistent volume mount mappings. However,GetSandboxesSandboxIDconstructsapi.SandboxDetailwithout populating theVolumeMountsfield, resulting in"volume_mounts": nullor omission in the JSON response. In contrast, the list endpointGET /v2/sandboxes(packages/api/internal/handlers/sandboxes_list.go:L292) correctly mapsVolumeMountsfor paused sandboxes viaconvertFromDBMountsToAPIMounts. -
Malformed
AliasSerialized as""(Empty String) instead ofnull/ Omission:
When a paused sandbox has no aliases,pausedAlias := firstAlias(lastSnapshot.Aliases)returns""(empty string).sandbox.Alias = &pausedAliasthen assigns a non-nil pointer to"". When serialized to JSON, this emits"alias": ""instead ofnullor omitting the property, violating the OpenAPI schema contract for optional string fields. -
Potential Nil Pointer Panic on
a.orchestrator:
GetSandboxesSandboxIDattempts to calla.orchestrator.GetSandboxwithout verifyinga.orchestrator != nil, causing panics in isolated unit tests and environments where the orchestrator client is nil.
Root Cause
In packages/api/internal/handlers/sandbox_get.go:L235-L265:
// Current implementation for paused sandboxes:
pausedAlias := firstAlias(lastSnapshot.Aliases)
sandbox = api.SandboxDetail{
// VolumeMounts is omitted completely
Alias: &pausedAlias, // Points to "" when len(Aliases) == 0
...
}
Comparison of metadata mapping across endpoints:
| Endpoint | Paused Sandbox VolumeMounts |
Empty Alias Representation |
|---|---|---|
GET /v2/sandboxes (sandboxes_list.go) |
Populated via convertFromDBMountsToAPIMounts |
nil (omitted) |
GET /sandboxes/{id} (Current) |
nil (omitted) |
&"" (serialized as "") |
GET /sandboxes/{id} (Expected) |
Populated from Config.VolumeMounts |
nil (omitted) |
Reproduction Steps
- Create a sandbox with persistent volume mounts:
POST /sandboxeswithvolume_mounts: [{"name": "my-vol", "path": "/mnt/data"}]. - Pause the sandbox:
POST /sandboxes/{id}/pause. - Query the paused sandbox:
GET /sandboxes/{id}. - Observed:
volume_mountsisnullor missing from the JSON payload.aliasis""(empty string) if no alias was assigned.
- Expected:
volume_mountscontains[{"name": "my-vol", "path": "/mnt/data"}].aliasisnullor omitted when no alias exists.
Technical Context
- File affected:
packages/api/internal/handlers/sandbox_get.go - Subsystem: Control Plane API / Sandboxes
- Impact: Medium (API Schema compliance, client SDK consistency, and paused sandbox metadata fidelity)
Proposed Changes
| # | Change | File(s) Affected | Complexity |
|---|---|---|---|
| 1 | Add nil check on a.orchestrator != nil before calling GetSandbox |
sandbox_get.go |
Trivial |
| 2 | Extract volumeMounts from lastSnapshot.Snapshot.Config.VolumeMounts and pass to api.SandboxDetail |
sandbox_get.go |
Low |
| 3 | Populate sandbox.Alias only when len(lastSnapshot.Aliases) > 0, leaving it nil otherwise |
sandbox_get.go |
Trivial |
| 4 | Add unit test asserting VolumeMounts and nil alias on paused snapshot |
sandbox_get_test.go |
Low |
- 主要言語
- Go
- スター
- 1.6k
- フォーク
- 438
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
e2b-dev/runtime のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
sandbox cache: StartRemoving state transition not broadcast, all allocations see stale Running state オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
e2b-dev/runtime の issue をすべて見る
似ている issue
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
microsoft/agent-framework-go#1179 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
[Bug]: OLLAMA_KEEP_ALIVE="5m" / "24h" crashes Ollama embedding and vision models with ValueError オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
infiniflow/ragflow#20223 · リアクション 1 件 ·
-
bug needs triage pkg/translator/faro
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
open-telemetry/opentelemetry-collector-contrib#51484 · コメント 1 件 ·