{"record":{"id":"fb5905e5c178ed07","repo":"Tencent/WeKnora","slug":"sandbox-build-e2b-client-w","errorCode":null,"errorMessage":"sandbox: build E2B client: %w","messagePattern":"sandbox: build E2B client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/manager.go","lineNumber":257,"sourceCode":"\t\treturn nil, fmt.Errorf(\"unknown sandbox type: %s\", sandboxType)\n\t}\n\n\tconfig := DefaultConfig()\n\tconfig.Type = sType\n\tif dockerImage != \"\" {\n\t\tconfig.DockerImage = dockerImage\n\t}\n\n\tvar client RemoteSandboxClient\n\tvar err error\n\tswitch sType {\n\tcase SandboxTypeCube:\n\t\tif client, err = NewCubeRemoteClient(config); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"sandbox: build Cube client: %w\", err)\n\t\t}\n\tcase SandboxTypeE2B:\n\t\tif client, err = NewE2BRemoteClient(config); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"sandbox: build E2B client: %w\", err)\n\t\t}\n\tcase SandboxTypeDocker:\n\t\tapplyDockerRuntimeDefaults(config)\n\t\tif client, err = NewDockerRemoteClient(config); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"sandbox: build Docker client: %w\", err)\n\t\t}\n\t}\n\tif client == nil {\n\t\treturn NewManager(config)\n\t}\n\treturn NewSessionBoundManager(SessionBoundManagerConfig{\n\t\tConfig:  config,\n\t\tClient:  client,\n\t\tStore:   NewMemorySessionSandboxBindingStore(),\n\t\tChecker: PermissiveSessionExistenceChecker{},\n\t})\n}\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/manager.go#L239-L275","documentation":"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).","triggerScenarios":"Calling NewManagerFromType(\"e2b\", ...) when the e2b SDK client cannot be built from Config — empty E2BAPIKey, invalid E2BAPIURL/E2BSandboxDomain, or transport creation failure.","commonSituations":"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.","solutions":["Set cfg.E2BAPIKey / E2B_API_KEY env var to a valid key before calling NewManagerFromType.","Check E2BAPIURL and E2BSandboxDomain values for your cloud or self-hosted deployment.","Unwrap the returned error to see the SDK's specific message and fix the implicated field.","Update the e2b SDK to a version consistent with the library's expected config surface."],"exampleFix":"// before\nmgr, err := NewManagerFromType(\"e2b\", \"\") // no key configured\n// after\nos.Setenv(\"E2B_API_KEY\", key)\nmgr, err := NewManagerFromType(\"e2b\", \"\")","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(cfg.E2BAPIKey) == \"\" {\n    return errors.New(\"E2B_API_KEY required before NewManagerFromType(\\\"e2b\\\")\")\n}","typeGuard":null,"tryCatchPattern":"mgr, err := NewManagerFromType(\"e2b\", \"\")\nif err != nil {\n    return fmt.Errorf(\"e2b client build failed: %w\", err)\n}","preventionTips":["Check E2B_API_KEY presence in CI/deployment startup checks","Validate E2BAPIURL and E2BSandboxDomain per environment (cloud vs self-hosted)","Keep the e2b SDK version aligned with library expectations"],"tags":["e2b","client-construction","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}