{"record":{"id":"fbc72c23edead15d","repo":"Tencent/WeKnora","slug":"e2b-remote-client-config-is-required","errorCode":null,"errorMessage":"e2b remote client config is required","messagePattern":"e2b remote client config is required","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/sandbox/e2b_remote_client.go","lineNumber":74,"sourceCode":"// keeps control-plane traffic on the process-wide transport while dialling\n// data-plane traffic at the configured gateway (see gateway_transport.go).\n// A nil pool falls back to the SDK defaults.\nfunc NewE2BRemoteClientWithPool(\n\tcfg *Config,\n\tpool *SandboxGatewayTransportPool,\n) (*E2BRemoteClient, error) {\n\tif pool == nil {\n\t\treturn newE2BRemoteClient(cfg, nil)\n\t}\n\treturn newE2BRemoteClient(cfg, pool.RoundTripperFor(cfg))\n}\n\nfunc newE2BRemoteClient(\n\tcfg *Config,\n\ttransport http.RoundTripper,\n) (*E2BRemoteClient, error) {\n\tif cfg == nil {\n\t\treturn nil, errors.New(\"e2b remote client config is required\")\n\t}\n\tif strings.TrimSpace(cfg.E2BAPIKey) == \"\" {\n\t\treturn nil, errors.New(\"E2BAPIKey is required for the E2B backend\")\n\t}\n\ttimeout := cfg.E2BHTTPTimeout\n\tif timeout <= 0 {\n\t\ttimeout = DefaultE2BHTTPTimeout\n\t}\n\t// Every E2B client speaks to envd through the compatibility shim, whether\n\t// or not a gateway is configured: the two details it rewrites belong to the\n\t// envd protocol itself, not to any one deployment. See envd_compat_transport.go.\n\thttpClient := &http.Client{\n\t\tTimeout:   timeout,\n\t\tTransport: NewEnvdCompatTransport(transport, DefaultSandboxExecUser),\n\t}\n\tclient, err := e2b.NewClient(e2b.ClientConfig{\n\t\tAPIKey:        cfg.E2BAPIKey,\n\t\tAPIBaseURL:    strings.TrimSpace(cfg.E2BAPIURL),","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/e2b_remote_client.go#L56-L92","documentation":"newE2BRemoteClient builds the HTTP client used to talk to E2B's envd shim and requires a non-nil *Config; without a config there is no API key, timeout, or endpoint information, so construction fails immediately. This is a constructor-time guard, hit before any network call.","triggerScenarios":"Calling NewE2BRemoteClientWithTransport or NewE2BRemoteClientWithPool with cfg == nil, usually because config assembly produced a nil pointer.","commonSituations":"Optional E2B config not loaded and nil passed through; a factory function returns nil config on an unhandled branch; tests constructing clients without fixture configs.","solutions":["Pass a populated *sandbox.Config to NewE2BRemoteClientWithTransport / NewE2BRemoteClientWithPool","Fix the config loader so it returns a valid Config (or a clear error) instead of nil","Set E2BAPIKey at the same time — a non-nil config with an empty key fails on the next check"],"exampleFix":"// before\nclient, err := sandbox.NewE2BRemoteClientWithTransport(nil, transport)\n// after\ncfg := &sandbox.Config{E2BAPIKey: os.Getenv(\"E2B_API_KEY\")}\nclient, err := sandbox.NewE2BRemoteClientWithTransport(cfg, transport)","handlingStrategy":"validation","validationCode":"if cfg == nil {\n    return errors.New(\"e2b backend: config must be loaded before constructing a client\")\n}","typeGuard":"func hasE2BConfig(cfg *sandbox.Config) bool { return cfg != nil }","tryCatchPattern":null,"preventionTips":["Construct backend clients only after a successful config load","Have factories return explicit errors instead of nil configs","Cover client construction with a test that passes a real fixture config"],"tags":["go","sandbox","e2b","config","nil-pointer"],"backgroundTag":"missing-configuration","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}