Repository navigation
Description
Summary
SandboxInterface.Create() now takes 7 positional parameters plus variadic opts after the sandbox templates refactor in PR #2781:
Create(ctx context.Context, workspace, name string, workload *SandboxWorkloadConfig,
policy *SandboxPolicy, providers []string, labels map[string]string,
opts ...CreateOptions) (*Sandbox, error)Four consecutive nilable parameters of different types makes call sites unreadable:
client.Sandboxes().Create(ctx, "default", "my-sandbox", nil, nil, nil, nil)Proposed Change
Bundle the creation parameters into a CreateSandboxParams struct:
type CreateSandboxParams struct {
Workload *SandboxWorkloadConfig
Policy *SandboxPolicy
Providers []string
Labels map[string]string
}The interface becomes:
Create(ctx context.Context, workspace, name string, params CreateSandboxParams, opts ...CreateOptions) (*Sandbox, error)This follows the k8s client-go pattern this SDK models, where creation parameters are bundled into typed structs rather than passed as positional arguments. Since PR #2781 is already a breaking change, the migration cost for this improvement is minimal.
The same pattern should apply to CreateFromTemplate() if it has a similar parameter list.
Context
Identified during PR #2781 code review (comment). The parameter list grew from 5 to 7+opts when policy and providers were promoted to top-level request fields.
Activity
elezar commentedon Aug 20, 2026
rhuss commentedon Sep 4, 2026
The triage assessment correctly identifies the deeper problem: Go reuses
SandboxSpecfor both creation input and resolved state, which leaks gateway-only fields likeDriverConfiginto the caller surface.That said, Rust and TypeScript already solved this. Both have a creation-only type (
SandboxSpec) that is distinct from the resolved output (SandboxRef). The Go fix should follow that established pattern rather than requiring a coordinated cross-SDK design effort.Proposed scoping:
CreateSandboxParams) that excludes gateway-resolved fields. Fold this into feat(sandbox)!: introduce reusable sandbox templates #2781 before it merges to avoid a second breaking change.SandboxSpecwith no curated creation type at all. That's a distinct gap worth its own tracking issue.CreateSandboxParamsin Go,SandboxSpecin Rust/TS) rather than requiring string-identical names across SDKs.Alignment happens by convergence on the same separation pattern, not by blocking on a formal specification document. Rust and TS are already there; Go joining them is the fix.
rhuss commentedon Sep 5, 2026
Revised Analysis
After deeper investigation, the original premise needs correction:
DriverConfigis a user-provided field, not a gateway-resolved leak. It lives onSandboxTemplate(proto field 11) and is intentionally part ofCreateSandboxRequest. The gateway routes the matching block to the active compute driver. Callers should be able to set it.This means the current
Create()signature on main is actually fine:The problem only arises in PR #2781, which decomposes
*SandboxSpecinto individual positional parameters:Proposed approach (revised):
*SandboxSpecas the single creation input forCreate(). Don't decompose it into positional params.CreateFromTemplate()takes a template name +*SandboxSpecfor optional overrides (policy, providers, etc.).labelsandannotationsinto functional options (WithLabels(),WithAnnotations()) to keep the positional parameter list short.This gives:
A dedicated
CreateSandboxParamsstruct is unnecessary since*SandboxSpecalready represents creation intent correctly. The only fields outside the spec (labels, annotations) are better served by functional options.Closing our earlier PR #3197 since it was based on the incorrect premise. The fix should be coordinated with #2781.
Add brainstorm: Go SDK Create() params struct
feat(sdk/go)!: replace positional labels with functional Create options
feat(sdk/go)!: replace positional labels with functional Create options
feat(sdk/go)!: replace positional labels with functional Create options
feat(sdk/go)!: replace positional labels with functional Create options
elezar commentedon Oct 16, 2026
Reopening this to get working on the Go SDK.
feat(sdk/go)!: replace positional labels with functional Create options
feat(sdk/go)!: replace positional labels with functional Create optio…