{"record":{"id":"04ec087d78e3edd2","repo":"Tencent/WeKnora","slug":"remote-sandbox-provider-unavailable-w","errorCode":null,"errorMessage":"remote sandbox provider unavailable: %w","messagePattern":"remote sandbox provider unavailable: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/sandbox/session_manager.go","lineNumber":214,"sourceCode":"\t\tactiveType: provider,\n\t}\n\n\t// Per-tenant managers are rebuilt on every request, so probing here would\n\t// add a remote round-trip to each one. When a tenant explicitly configures\n\t// a backend, an unreachable provider must fail at first use rather than\n\t// substituting a different execution environment.\n\tif deps.SkipHealthProbe {\n\t\treturn m, nil\n\t}\n\n\t// Health probe uses the provider's own HTTP timeout.\n\tprobeCtx, cancel := context.WithTimeout(\n\t\tcontext.Background(),\n\t\teffectiveHTTPTimeout(provider, cfg),\n\t)\n\tdefer cancel()\n\tif err := deps.Client.Health(probeCtx); err != nil {\n\t\treturn nil, fmt.Errorf(\"remote sandbox provider unavailable: %w\", err)\n\t}\n\treturn m, nil\n}\n\n// GetType reports the current effective sandbox type.\nfunc (m *SessionBoundManager) GetType() SandboxType {\n\tif m == nil {\n\t\treturn SandboxTypeDisabled\n\t}\n\tm.mu.RLock()\n\tdefer m.mu.RUnlock()\n\treturn m.activeType\n}\n\n// GetSandbox exposes a diagnostic Sandbox for callers that need to inspect\n// availability. Returns a stateless RemoteSandbox surface for the current\n// provider.\nfunc (m *SessionBoundManager) GetSandbox() Sandbox {","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/session_manager.go#L196-L232","documentation":"During NewSessionBoundManager, the constructor performs a health probe against the remote sandbox provider (deps.Client.Health) using the provider's HTTP timeout. If the provider does not respond healthily, construction fails with \"remote sandbox provider unavailable\". Per-tenant managers may skip this probe via SkipHealthProbe, in which case the failure surfaces at first use instead.","triggerScenarios":"Calling NewSessionBoundManager without SkipHealthProbe when the remote provider's /health endpoint is unreachable, returns an error, or exceeds effectiveHTTPTimeout(provider, cfg).","commonSituations":"E2B/Cube/Docker-remote service down or restarted, wrong API endpoint or region in config, missing/expired API key causing auth failures on health, network egress blocked, firewall or DNS issues, or HTTP timeout set too low for a slow provider.","solutions":["Check the wrapped error: connection refused/DNS means the provider is down or the endpoint is wrong; timeout means raise effectiveHTTPTimeout or fix network latency.","Verify the provider service is running and reachable (curl the health endpoint from the same host).","Confirm endpoint URL and API credentials in the sandbox config; expired keys often fail health checks.","If this is a per-tenant manager rebuilt per request and first-use failure is acceptable, set deps.SkipHealthProbe = true to defer the check.","Add retry/backoff around manager construction for transient provider restarts."],"exampleFix":"// before\nmgr, err := sandbox.NewSessionBoundManager(ctx, cfg, deps) // probe fails on transient blip\n// after\nvar mgr *sandbox.SessionBoundManager\nfor i := 0; i < 3; i++ {\n    mgr, err = sandbox.NewSessionBoundManager(ctx, cfg, deps)\n    if err == nil {\n        break\n    }\n    time.Sleep(time.Duration(1<<i) * time.Second)\n}","handlingStrategy":"retry","validationCode":"// pre-check provider reachability before constructing\nprobeCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\ndefer cancel()\nif err := deps.Client.Health(probeCtx); err != nil {\n    return fmt.Errorf(\"provider unreachable before init: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"var mgr *sandbox.SessionBoundManager\nvar err error\nfor attempt := 0; attempt < 3; attempt++ {\n    mgr, err = sandbox.NewSessionBoundManager(ctx, cfg, deps)\n    if err == nil { break }\n    select {\n    case <-ctx.Done():\n        return ctx.Err()\n    case <-time.After(time.Duration(1<<attempt) * time.Second):\n    }\n}\nif err != nil {\n    return nil, fmt.Errorf(\"sandbox provider unavailable: %w\", err)\n}","preventionTips":["Monitor the sandbox provider's health endpoint and alert on downtime.","Set realistic HTTP timeouts in the config for your provider's latency.","Verify endpoint URLs and API keys in configuration before deploy.","Use SkipHealthProbe only for per-tenant managers where first-use failure is acceptable.","Add readiness probes so traffic doesn't reach the app while the provider is down."],"tags":["go","sandbox","health-check","network","timeout"],"backgroundTag":"service-health-check-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}