Tencent/WeKnora · error · ErrUnsupportedSandboxType

ErrUnsupportedSandboxType

ErrUnsupportedSandboxType

Error message

%w %q

What it means

ParseSandboxType converts a tenant's raw sandbox-type string into the known SandboxType constants (e2b, docker, disabled). Any other value yields this sentinel-wrapped error (ErrUnsupportedSandboxType), because the resolver cannot build a provider request for an unknown sandbox backend.

Source

Thrown at internal/sandbox/tenant_config.go:236

// a sentinel so callers can classify it as bad input without matching on the
// message text.
var ErrUnsupportedSandboxType = errors.New("sandbox: unsupported sandbox type")

// ParseSandboxType maps a stored string onto a SandboxType. Unknown values are
// rejected so a typo surfaces when the admin saves the config, instead of
// silently disabling that tenant's sandbox at first use.
func ParseSandboxType(raw string) (SandboxType, error) {
	switch SandboxType(raw) {
	case SandboxTypeCube:
		return SandboxTypeCube, nil
	case SandboxTypeE2B:
		return SandboxTypeE2B, nil
	case SandboxTypeDocker:
		return SandboxTypeDocker, nil
	case SandboxTypeDisabled:
		return SandboxTypeDisabled, nil
	default:
		return "", fmt.Errorf("%w %q", ErrUnsupportedSandboxType, raw)
	}
}

// EffectiveTemplateID returns the template the given provider will use.
func EffectiveTemplateID(cfg *Config) string {
	if cfg == nil {
		return ""
	}
	switch cfg.Type {
	case SandboxTypeCube:
		return cfg.CubeTemplate
	case SandboxTypeE2B:
		return cfg.E2BTemplate
	case SandboxTypeDocker:
		// The image is what a template ID is for the MicroVM backends: the
		// pre-baked filesystem a sandbox starts from.
		return cfg.DockerImage
	default:

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set the sandbox type to one of the supported values: "e2b", "docker", or "disabled".
  2. Check errors.Is(err, sandbox.ErrUnsupportedSandboxType) and log/report the offending raw value from the error text.
  3. After a library upgrade, re-validate stored tenant configs against the current enum before use.

Example fix

// before
"sandbox_type": "firecracker"
// after
"sandbox_type": "docker"
Defensive patterns

Strategy: validation

Validate before calling

valid := map[string]bool{"e2b": true, "docker": true, "disabled": true}
if !valid[strings.TrimSpace(strings.ToLower(cfg.SandboxType))] {
    return fmt.Errorf("unsupported sandbox type %q", cfg.SandboxType)
}

Type guard

func knownSandboxType(s string) bool {
    switch sandbox.SandboxType(strings.TrimSpace(strings.ToLower(s))) {
    case sandbox.SandboxTypeE2B, sandbox.SandboxTypeDocker, sandbox.SandboxTypeDisabled:
        return true
    }
    return false
}

Try / catch

t, err := sandbox.ParseSandboxType(raw)
if errors.Is(err, sandbox.ErrUnsupportedSandboxType) {
    return fmt.Errorf("config error: sandbox type %q not supported; use e2b|docker|disabled", raw)
}

Prevention

When it happens

Trigger: SanitizeSandboxConfig or ResolveEffectiveConfig encountering a Config whose sandbox type string is not one of SandboxTypeE2B, SandboxTypeDocker, SandboxTypeDisabled — e.g. a typo like "E2B " (whitespace/case mismatch if not normalized), "local", or "firecracker".

Common situations: Hand-edited tenant config in the database; renamed enum values across library versions; provisioning scripts writing a provider name the library doesn't know.

Related errors


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/990d2c6be2bcf71d. Report an issue: GitHub.