{"record":{"id":"eae5b908ca9ac4ec","repo":"Tencent/WeKnora","slug":"bind-owned-remote-sandbox-w","errorCode":null,"errorMessage":"bind owned remote sandbox: %w","messagePattern":"bind owned remote sandbox: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/session_lifecycle.go","lineNumber":328,"sourceCode":"\t\t\tif CanReplaceRemoteBinding(err) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn nil, false, fmt.Errorf(\"connect owned remote sandbox: %w\", err)\n\t\t}\n\t\tif err := l.validateHandle(handle, summary.ID); err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\tif err := l.cleanupOwnedDuplicates(ctx, summaries, summary.ID, metadata); err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\ttemplateID := summary.TemplateID\n\t\tif templateID == \"\" {\n\t\t\ttemplateID = l.createRequest.TemplateID\n\t\t}\n\t\tbinding := l.newBinding(key, summary.ID, templateID, summary.StartedAt)\n\t\tcreated, err := l.bindings.Create(ctx, key, binding)\n\t\tif err != nil {\n\t\t\treturn nil, false, fmt.Errorf(\"bind owned remote sandbox: %w\", err)\n\t\t}\n\t\tif created {\n\t\t\treturn handle, true, nil\n\t\t}\n\t\twinner, err := l.connectWinner(ctx, key)\n\t\tif err != nil {\n\t\t\treturn nil, false, err\n\t\t}\n\t\treturn winner, true, nil\n\t}\n\treturn nil, false, nil\n}\n\nfunc (l *remoteSessionLifecycle) createAndBind(\n\tctx context.Context,\n\tkey SessionSandboxKey,\n) (RemoteSandboxHandle, error) {\n\trequest := l.createRequest","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/session_lifecycle.go#L310-L346","documentation":"This error wraps a failure from the binding store's Create when the lifecycle, having connected to a recovered orphaned sandbox, tries to record the SessionSandboxBinding for it. If persisting the binding fails, the recovered handle is abandoned and 'bind owned remote sandbox: %w' is returned, since reusing the sandbox without a durable binding would break future resolution.","triggerScenarios":"l.bindings.Create(ctx, key, binding) returns an error after a successful Connect during recoverOwnedSandbox — the binding store's backend (database, KV, lock store) is unavailable, the write conflicts, permissions are insufficient, or the record schema changed.","commonSituations":"Binding-store database down or migrated; concurrent writers causing store-level conflicts; permissions revoked on the binding table/bucket; metadata (template ID fallback to createRequest.TemplateID) producing an invalid record; disk/full or quota errors on the store.","solutions":["Check the binding store's availability and the wrapped error for backend-specific detail","Verify write permissions on the binding storage backend","Retry resolution once the store recovers — the orphan will be re-discovered and rebound","Inspect recent schema/migrations of the binding store for incompatibilities"],"exampleFix":"// before\ncreated, err := bindings.Create(ctx, key, binding) // fails: store unavailable\n// after\ncreated, err := bindings.Create(ctx, key, binding)\nif err != nil {\n    // backoff and retry once before giving up\n    time.Sleep(backoff)\n    created, err = bindings.Create(ctx, key, binding)\n}","handlingStrategy":"retry","validationCode":"// verify the binding store is writable before starting resolution\nif err := bindings.HealthCheck(ctx); err != nil {\n    return fmt.Errorf(\"binding store unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"handle, err := session.Resolve(ctx, key)\nif err != nil && strings.HasPrefix(err.Error(), \"bind owned remote sandbox:\") {\n    err = retryWithBackoff(ctx, 3, func() error { handle, err = session.Resolve(ctx, key); return err })\n}","preventionTips":["Health-check the binding store before batch resolution","Add idempotent, retry-safe Create semantics in the binding store","Monitor binding-store latency and error rates","Keep binding record schemas backward compatible during migrations"],"tags":["storage","binding-store","persistence","sandbox-recovery"],"backgroundTag":"binding-write-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}