{"record":{"id":"f2f44c5366d62ff5","repo":"Tencent/WeKnora","slug":"sandbox-build-cube-client-w","errorCode":null,"errorMessage":"sandbox: build Cube client: %w","messagePattern":"sandbox: build Cube client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/manager.go","lineNumber":253,"sourceCode":"\t\tsType = SandboxTypeE2B\n\tcase \"disabled\", \"\":\n\t\tsType = SandboxTypeDisabled\n\tdefault:\n\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(),","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/manager.go#L235-L271","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the Cube credentials (API key/token) in Config or via the environment.","Verify the Cube API endpoint URL in the config is correct and reachable.","Unwrap the error to read the underlying Cube client failure and fix that field.","Confirm the Cube client library version matches the config fields you set."],"exampleFix":"// before\ncfg := DefaultConfig() // Cube credentials missing\nmgr, err := NewManagerFromType(\"cube\", \"\")\n// after\ncfg.CubeAPIKey = os.Getenv(\"CUBE_API_KEY\")\nif cfg.CubeAPIKey == \"\" { return errors.New(\"CUBE_API_KEY required\") }\nmgr, err := NewManagerFromType(\"cube\", \"\")","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(cfg.CubeAPIKey) == \"\" {\n    return errors.New(\"Cube credentials required before NewManagerFromType(\\\"cube\\\")\")\n}","typeGuard":null,"tryCatchPattern":"mgr, err := NewManagerFromType(\"cube\", \"\")\nif err != nil {\n    return fmt.Errorf(\"cube client build failed: %w\", err)\n}","preventionTips":["Export Cube API credentials before process start and verify at boot","Validate the Cube endpoint URL format before constructing the manager","Unwrap and log the root cause for faster diagnosis in production"],"tags":["cube","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"}