An open-source, faster Devin alternative
TypeScript
fix(sandbox): default networkEnabled=true so dashboard stops mislabeling sandboxes
motatoes4af8d30f5a1b
diff --git a/internal/api/image_builder.go b/internal/api/image_builder.goindex 2321afb3..9d1d4d80 100644--- a/internal/api/image_builder.go+++ b/internal/api/image_builder.go@@ -399,7 +399,8 @@ func (s *Server) buildImage(ctx context.Context, orgID uuid.UUID, manifest *Imag}_ = resp} else if s.manager != nil {- cfg.NetworkEnabled = true+ t := true+ cfg.NetworkEnabled = &tsb, err := s.manager.Create(ctx, cfg)if err != nil {return uuid.Nil, fmt.Errorf("failed to create build sandbox: %w", err)diff --git a/internal/api/sandbox.go b/internal/api/sandbox.goindex ee8fbb76..ca337b04 100644--- a/internal/api/sandbox.go+++ b/internal/api/sandbox.go@@ -26,6 +26,9 @@ func (s *Server) createSandbox(c echo.Context) error {"error": "invalid request body: " + err.Error(),})}+ // Default networkEnabled=true when caller omits it, so the value persisted+ // to sandbox_sessions.config_json is explicit and forks inherit it correctly.+ cfg.EnsureNetworkEnabledDefault()// Validate CPU/memory against allowed tiers.// Allowed tiers (memoryMB → vCPU): 1024→1, 4096→1, 8192→2, 16384→4, 32768→8, 65536→16.@@ -485,7 +488,7 @@ func (s *Server) createSandboxRemote(c echo.Context, ctx context.Context, cfg tyTemplate: cfg.Template,Timeout: int32(cfg.Timeout),Envs: cfg.Envs,- NetworkEnabled: cfg.NetworkEnabled,+ NetworkEnabled: cfg.IsNetworkEnabled(),Port: int32(cfg.Port),TemplateRootfsKey: templateRootfsKey,TemplateWorkspaceKey: templateWorkspaceKey,@@ -2254,6 +2257,10 @@ func (s *Server) createFromCheckpointCore(c echo.Context, userEnvs map[string]st// Parse the original sandbox config to reuse settingsvar originalCfg types.SandboxConfig_ = json.Unmarshal(cp.SandboxConfig, &originalCfg)+ // Older checkpoints predate the networkEnabled default-to-true normalization+ // and persisted no value (or false from the old non-pointer bool). Forks+ // should still come up with networking on.+ originalCfg.EnsureNetworkEnabledDefault()// Secret store resolution — supports layering:// Resolve stores in order: BaseSecretStore → SecretStore → user's store.@@ -2396,7 +2403,7 @@ func (s *Server) createFromCheckpointCore(c echo.Context, userEnvs map[string]stEnvs: originalCfg.Envs,MemoryMb: int32(originalCfg.MemoryMB),CpuCount: int32(originalCfg.CpuCount),- NetworkEnabled: originalCfg.NetworkEnabled,+ NetworkEnabled: originalCfg.IsNetworkEnabled(),Port: int32(originalCfg.Port),TemplateRootfsKey: *cp.RootfsS3Key,TemplateWorkspaceKey: *cp.WorkspaceS3Key,diff --git a/internal/worker/grpc_server.go b/internal/worker/grpc_server.goindex 6806bae7..3db6a7c4 100644--- a/internal/worker/grpc_server.go+++ b/internal/worker/grpc_server.go@@ -152,7 +152,7 @@ func (s *GRPCServer) CreateSandbox(ctx context.Context, req *pb.CreateSandboxReqEnvs: req.Envs,MemoryMB: int(req.MemoryMb),CpuCount: int(req.CpuCount),- NetworkEnabled: req.NetworkEnabled,+ NetworkEnabled: &req.NetworkEnabled,ImageRef: req.ImageRef,Port: int(req.Port),SandboxID: req.SandboxId, // use server-assigned ID if provideddiff --git a/pkg/types/sandbox.go b/pkg/types/sandbox.goindex f72d77bd..9919dd47 100644--- a/pkg/types/sandbox.go+++ b/pkg/types/sandbox.go@@ -48,7 +48,9 @@ type SandboxConfig struct {DiskMB int `json:"diskMB,omitempty"` // workspace disk in MB (default 20480)Envs map[string]string `json:"envs,omitempty"`Port int `json:"port,omitempty"` // container port to expose via subdomain (default 80)- NetworkEnabled bool `json:"networkEnabled,omitempty"`+ // NetworkEnabled is a pointer so we can distinguish "unset" from+ // "explicitly false". Unset defaults to true (see IsNetworkEnabled).+ NetworkEnabled *bool `json:"networkEnabled,omitempty"`ImageRef string `json:"imageRef,omitempty"` // resolved ECR URI for custom templates// Sandbox snapshot template: S3 keys for rootfs and workspace drives.// When set, the sandbox boots from these drives instead of the standard base image.@@ -107,6 +109,26 @@ var AllowedResourceTiers = []ResourceTier{{MemoryMB: 65536, VCPUs: 16},}+// IsNetworkEnabled returns the effective NetworkEnabled value, defaulting to+// true when unset. Direct deref is unsafe because older persisted configs and+// clients that omit the field produce nil.+func (c SandboxConfig) IsNetworkEnabled() bool {+ if c.NetworkEnabled == nil {+ return true+ }+ return *c.NetworkEnabled+}++// EnsureNetworkEnabledDefault sets NetworkEnabled to true when unset, so the+// value persisted into the DB is explicit and survives round-trips (e.g. fork+// from checkpoint).+func (c *SandboxConfig) EnsureNetworkEnabledDefault() {+ if c.NetworkEnabled == nil {+ t := true+ c.NetworkEnabled = &t+ }+}+// ValidateMemoryMB checks that memoryMB matches an allowed tier and returns the corresponding vCPU count.// Returns 0, nil if memoryMB is 0 (use defaults).func ValidateMemoryMB(memoryMB int) (vcpus int, err error) {