Tencent/WeKnora · error

invalid sandbox config: %w

Error message

invalid sandbox config: %w

What it means

NewSessionBoundManager validates the supplied (or default) Config before wiring dependencies. If ValidateConfig reports any invalid field — bad timeouts, negative TTLs, malformed endpoints, etc. — construction fails with 'invalid sandbox config' wrapping the specific validation error.

Source

Thrown at internal/sandbox/session_manager.go:128

	// See NewSessionBoundManager.
	SkipHealthProbe bool
}

// NewSessionBoundManager wires the manager with an explicit RemoteSandboxClient
// backend, binding store, and session existence checker. Every persistent
// operation flows through these three dependencies; the manager never keeps
// authoritative session→sandbox state locally.
//
// Provider identity comes from deps.Client.Provider() — not Config.Type —
// so test harnesses and custom wiring that inject a different client backend
// always project the correct template, TTL, and health timeout.
func NewSessionBoundManager(deps SessionBoundManagerConfig) (*SessionBoundManager, error) {
	cfg := deps.Config
	if cfg == nil {
		cfg = DefaultConfig()
	}
	if err := ValidateConfig(cfg); err != nil {
		return nil, fmt.Errorf("invalid sandbox config: %w", err)
	}
	if deps.Client == nil {
		return nil, errors.New("session bound manager requires a RemoteSandboxClient")
	}
	if deps.Store == nil {
		return nil, errors.New("session bound manager requires a SessionSandboxBindingStore")
	}
	if deps.Checker == nil {
		return nil, errors.New("session bound manager requires a SessionExistenceChecker")
	}

	provider := deps.Client.Provider()
	if !isRemoteProvider(provider) {
		return nil, fmt.Errorf("sandbox: unsupported remote provider %q", provider)
	}

	// Apply the provider's tuning defaults so downstream code reads only
	// non-zero TTL / timeout fields. Endpoint defaults are deliberately not

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Read the wrapped ValidateConfig error — it names the exact offending field
  2. Fix the invalid Config field (ensure positive TTLs/timeouts and well-formed endpoints)
  3. If no Config is needed, pass nil to use DefaultConfig()
  4. Compare against DefaultConfig() to see expected field shapes

Example fix

// before
cfg.Timeout = -5 * time.Second
mgr, err := sandbox.NewSessionBoundManager(deps)
// after
cfg.Timeout = 30 * time.Second
mgr, err := sandbox.NewSessionBoundManager(deps)
Defensive patterns

Strategy: validation

Validate before calling

cfg := deps.Config
if cfg == nil { cfg = sandbox.DefaultConfig() }
if err := sandbox.ValidateConfig(cfg); err != nil {
    return nil, fmt.Errorf("config rejected before construction: %w", err)
}

Try / catch

mgr, err := sandbox.NewSessionBoundManager(deps)
if err != nil && strings.Contains(err.Error(), "invalid sandbox config") {
    return nil, fmt.Errorf("fix sandbox config: %w", err)
}

Prevention

When it happens

Trigger: Calling NewSessionBoundManager (directly or via NewManagerFromType / integration managers) with a Config containing invalid values: non-positive durations, invalid endpoint URLs, mutually inconsistent fields.

Common situations: Typo'd environment variable parsing (e.g. TTL as '0' or negative), hand-edited named configs missing required fields, upgrading to a version with stricter validation rules.

Related errors


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