Skip to content

fix(api): populate volume mounts and normalize alias for paused sandboxes in GetSandboxesSandboxID - #3576

Open
chill-czar wants to merge 1 commit into
e2b-dev:mainfrom
chill-czar:fix/sandbox-get-paused-metadata
Open

fix(api): populate volume mounts and normalize alias for paused sandboxes in GetSandboxesSandboxID#3576
chill-czar wants to merge 1 commit into
e2b-dev:mainfrom
chill-czar:fix/sandbox-get-paused-metadata

Conversation

@chill-czar

@chill-czar chill-czar commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Closes #3575

Summary

  • Populate VolumeMounts from lastSnapshot.Snapshot.Config.VolumeMounts in GetSandboxesSandboxID for paused sandboxes using convertFromDBMountsToAPIMounts, matching GET /v2/sandboxes.
  • Normalize sandbox.Alias so it remains nil (omitted from JSON) when len(lastSnapshot.Aliases) == 0 instead of pointing to an empty string &"".
  • Add defensive nil guard for a.orchestrator != nil before querying active sandboxes.
  • Add test coverage in packages/api/internal/handlers/sandbox_get_test.go (TestGetSandboxesSandboxID_PausedWithVolumeMountsAndNilAlias).

Why

In packages/api/internal/handlers/sandbox_get.go, GET /sandboxes/{id} did not populate VolumeMounts for paused sandboxes, causing a discrepancy with GET /v2/sandboxes where snapshot volume mounts are properly returned. Furthermore, firstAlias returns "" when there are no aliases; assigning a pointer to this string caused JSON output to serialize "alias": "" instead of omitting the field or returning null.

Diff Overview

 		var alias *string
 		if len(lastSnapshot.Aliases) > 0 {
 			first := lastSnapshot.Aliases[0]
 			alias = &first
 		}
 
+		var volumeMounts []queries.VolumeMount
+		if lastSnapshot.Snapshot.Config.VolumeMounts != nil {
+			volumeMounts = *lastSnapshot.Snapshot.Config.VolumeMounts
+		}
+
 		sandbox = api.SandboxDetail{
 			ClientID:     lastSnapshot.Snapshot.BaseTemplateID,
 			TemplateID:   lastSnapshot.Snapshot.BaseTemplateID,
 			Alias:        alias,
+			VolumeMounts: convertFromDBMountsToAPIMounts(volumeMounts),
 			SandboxID:    sandboxID,

Test Plan

  • Unit test: go test -v ./packages/api/internal/handlers -run TestGetSandboxesSandboxID_PausedWithVolumeMountsAndNilAlias
  • Package test suite passes: go test -v ./packages/api/internal/handlers/...
  • Linter & Formatter pass: make fmt and make lint
  • Verified VolumeMounts is preserved on paused sandboxes and Alias is omitted when empty

/cc @jakubno @dobrac @ValentaTomas @arkamar @tvi

@chill-czar

Copy link
Copy Markdown
Contributor Author

@claude review

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.

fix(api): GetSandboxesSandboxID omits VolumeMounts and sets empty string Alias for paused sandboxes

1 participant