{"record":{"id":"290e033f88d4872d","repo":"Tencent/WeKnora","slug":"remote-sandbox-get-returned-id-q-for-binding-q","errorCode":null,"errorMessage":"remote sandbox Get returned ID %q for binding %q","messagePattern":"remote sandbox Get returned ID %q for binding %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/session_lifecycle.go","lineNumber":247,"sourceCode":"\treturn l.createAndBind(ctx, key)\n}\n\nfunc (l *remoteSessionLifecycle) connectBinding(\n\tctx context.Context,\n\tbinding SessionSandboxBinding,\n) (RemoteSandboxHandle, bool, error) {\n\tsummary, err := l.client.Get(ctx, binding.SandboxID)\n\tif err != nil {\n\t\tif CanReplaceRemoteBinding(err) {\n\t\t\treturn nil, true, nil\n\t\t}\n\t\treturn nil, false, fmt.Errorf(\"get bound remote sandbox: %w\", err)\n\t}\n\tif summary == nil {\n\t\treturn nil, false, errors.New(\"remote sandbox Get returned nil summary\")\n\t}\n\tif summary.ID != binding.SandboxID {\n\t\treturn nil, false, fmt.Errorf(\n\t\t\t\"remote sandbox Get returned ID %q for binding %q\",\n\t\t\tsummary.ID,\n\t\t\tbinding.SandboxID,\n\t\t)\n\t}\n\tif summary.State == RemoteStateTerminal {\n\t\treturn nil, true, nil\n\t}\n\n\thandle, err := l.client.Connect(ctx, binding.SandboxID)\n\tif err != nil {\n\t\tif CanReplaceRemoteBinding(err) {\n\t\t\treturn nil, true, nil\n\t\t}\n\t\treturn nil, false, fmt.Errorf(\"connect bound remote sandbox: %w\", err)\n\t}\n\tif err := l.validateHandle(handle, binding.SandboxID); err != nil {\n\t\treturn nil, false, err","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/session_lifecycle.go#L229-L265","documentation":"This error indicates an invariant violation: the provider's Get returned a sandbox summary whose ID differs from the sandbox ID stored in the session binding. Since Get was called with binding.SandboxID, a mismatched ID means the provider is returning inconsistent or corrupted data, so the library aborts rather than connecting to an unexpected sandbox.","triggerScenarios":"client.Get(ctx, binding.SandboxID) succeeds but the returned summary.ID != binding.SandboxID — essentially only possible with a misbehaving or buggy provider client implementation, ID normalization differences (case/whitespace), or a provider proxy rewriting IDs.","commonSituations":"Custom or mock RemoteClient implementations returning canned summaries with different IDs; provider SDK normalizing IDs (e.g. trimming or lowercasing); routing through a proxy/gateway that remaps sandbox IDs; stale bindings reused across provider account/project switches.","solutions":["Check the RemoteClient implementation for ID normalization (trim/case changes) and make Get echo the requested ID verbatim","Delete the stale binding and re-resolve so a fresh binding is created with the provider's actual ID","Verify you are talking to the same provider project/account that created the sandbox","If using a proxy or custom transport, ensure it does not rewrite sandbox identifiers"],"exampleFix":"// before (custom client returns normalized ID)\nreturn &RemoteSandboxSummary{ID: strings.ToLower(id)}, nil\n// after\nreturn &RemoteSandboxSummary{ID: id}, nil // echo the requested ID exactly","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func saneSummary(summary *sandbox.RemoteSandboxSummary, want string) bool {\n    return summary != nil && summary.ID == want\n}","tryCatchPattern":"handle, err := session.Resolve(ctx, key)\nif err != nil && strings.Contains(err.Error(), \"returned ID\") {\n    // provider returned a mismatched ID: purge binding and re-resolve\n    _ = bindings.Delete(ctx, key)\n    handle, err = session.Resolve(ctx, key)\n}","preventionTips":["Use the stock provider client rather than custom wrappers that transform IDs","Write contract tests asserting Get echoes the requested sandbox ID","Avoid proxies that rewrite resource identifiers","Keep bindings and sandboxes within the same provider project/account"],"tags":["provider-invariant","binding-resolution","data-integrity"],"backgroundTag":"sandbox-id-mismatch","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}