Tencent/WeKnora · error

sandbox: build E2B client: %w

Error message

sandbox: build E2B client: %w

What it means

NewManagerFromType, for the e2b backend, builds the client via NewE2BRemoteClient(config); failure is wrapped as "sandbox: build E2B client: %w". This is the NewManagerFromType-level wrapper around the same underlying construction error that newE2BRemoteClient reports (typically missing API key or bad endpoint/domain).

Source

Thrown at internal/sandbox/manager.go:257

		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(),
		Checker: PermissiveSessionExistenceChecker{},
	})
}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Set cfg.E2BAPIKey / E2B_API_KEY env var to a valid key before calling NewManagerFromType.
  2. Check E2BAPIURL and E2BSandboxDomain values for your cloud or self-hosted deployment.
  3. Unwrap the returned error to see the SDK's specific message and fix the implicated field.
  4. Update the e2b SDK to a version consistent with the library's expected config surface.

Example fix

// before
mgr, err := NewManagerFromType("e2b", "") // no key configured
// after
os.Setenv("E2B_API_KEY", key)
mgr, err := NewManagerFromType("e2b", "")
Defensive patterns

Strategy: validation

Validate before calling

if strings.TrimSpace(cfg.E2BAPIKey) == "" {
    return errors.New("E2B_API_KEY required before NewManagerFromType(\"e2b\")")
}

Try / catch

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

Prevention

When it happens

Trigger: Calling NewManagerFromType("e2b", ...) when the e2b SDK client cannot be built from Config — empty E2BAPIKey, invalid E2BAPIURL/E2BSandboxDomain, or transport creation failure.

Common situations: E2B_API_KEY absent in CI/production environments; misconfigured E2B_API_URL for self-hosted E2B; sandbox domain typo for enterprise deployments; SDK version mismatch requiring extra config.

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/fb5905e5c178ed07. Report an issue: GitHub.