Tencent/WeKnora · error

sandbox: build Cube client: %w

Error message

sandbox: build Cube client: %w

What it means

NewManagerFromType, for the cube backend, builds a remote client via NewCubeRemoteClient; any construction failure is wrapped as "sandbox: build Cube client: %w" and no manager is returned. The wrapped error carries the Cube client's own reason (usually missing credentials or invalid endpoint).

Source

Thrown at internal/sandbox/manager.go:253

		sType = SandboxTypeE2B
	case "disabled", "":
		sType = SandboxTypeDisabled
	default:
		return nil, fmt.Errorf("unknown sandbox type: %s", sandboxType)
	}

	config := DefaultConfig()
	config.Type = sType
	if dockerImage != "" {
		config.DockerImage = dockerImage
	}

	var client RemoteSandboxClient
	var err error
	switch sType {
	case SandboxTypeCube:
		if client, err = NewCubeRemoteClient(config); err != nil {
			return nil, fmt.Errorf("sandbox: build Cube client: %w", err)
		}
	case SandboxTypeE2B:
		if client, err = NewE2BRemoteClient(config); err != nil {
			return nil, fmt.Errorf("sandbox: build E2B client: %w", err)
		}
	case SandboxTypeDocker:
		applyDockerRuntimeDefaults(config)
		if client, err = NewDockerRemoteClient(config); err != nil {
			return nil, fmt.Errorf("sandbox: build Docker client: %w", err)
		}
	}
	if client == nil {
		return NewManager(config)
	}
	return NewSessionBoundManager(SessionBoundManagerConfig{
		Config:  config,
		Client:  client,
		Store:   NewMemorySessionSandboxBindingStore(),

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set the Cube credentials (API key/token) in Config or via the environment.
  2. Verify the Cube API endpoint URL in the config is correct and reachable.
  3. Unwrap the error to read the underlying Cube client failure and fix that field.
  4. Confirm the Cube client library version matches the config fields you set.

Example fix

// before
cfg := DefaultConfig() // Cube credentials missing
mgr, err := NewManagerFromType("cube", "")
// after
cfg.CubeAPIKey = os.Getenv("CUBE_API_KEY")
if cfg.CubeAPIKey == "" { return errors.New("CUBE_API_KEY required") }
mgr, err := NewManagerFromType("cube", "")
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(cfg.CubeAPIKey) == "" {
    return errors.New("Cube credentials required before NewManagerFromType(\"cube\")")
}

Try / catch

mgr, err := NewManagerFromType("cube", "")
if err != nil {
    return fmt.Errorf("cube client build failed: %w", err)
}

Prevention

When it happens

Trigger: Calling NewManagerFromType("cube", ...) when NewCubeRemoteClient(config) fails — e.g. missing Cube API key/token, invalid Cube API URL, or transport setup errors inside the client constructor.

Common situations: CUBE_API_KEY not exported in the deployment environment; self-hosted Cube endpoint URL misconfigured in Config; network/CA certificate issues at client-build time; SDK upgrade introducing new required config fields.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


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