Skip to content

Commit 2d1abe0

Browse files
committed
fix(api): populate cpuCount/memoryMB/diskSizeMB/createdAt in snapshot create response
POST /sandboxes/{id}/snapshots was returning zero values for the four new required SnapshotInfo fields. Populate them from the source sandbox, which already has VCpu, RamMB, TotalDiskSizeMB in memory at the point of return.
1 parent 7628cd3 commit 2d1abe0

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎packages/api/internal/handlers/snapshot_template_create.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"github.com/e2b-dev/infra/packages/shared/pkg/ginutils"
1919
"github.com/e2b-dev/infra/packages/shared/pkg/id"
2020
"github.com/e2b-dev/infra/packages/shared/pkg/logger"
21+
"time"
22+
2123
"github.com/e2b-dev/infra/packages/shared/pkg/telemetry"
2224
sharedUtils "github.com/e2b-dev/infra/packages/shared/pkg/utils"
2325
)
@@ -161,5 +163,9 @@ func (a *APIStore) PostSandboxesSandboxIDSnapshots(c *gin.Context, sandboxID api
161163
c.JSON(http.StatusCreated, api.SnapshotInfo{
162164
SnapshotID: snapshotID,
163165
Names: names,
166+
CpuCount: int32(sbx.VCpu),
167+
MemoryMB: int32(sbx.RamMB),
168+
DiskSizeMB: int32(sbx.TotalDiskSizeMB),
169+
CreatedAt: time.Now(),
164170
})
165171
}

0 commit comments

Comments
 (0)