{"record":{"id":"bc48ca22d320ad69","repo":"tursodatabase/turso","slug":"remote-close-returned-unexpected-result-type-res","errorCode":null,"errorMessage":"Remote close returned unexpected result type: {result.Type}","messagePattern":"Remote close returned unexpected result type: (.+?)","errorType":"exception","errorClass":"TursoException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoRemoteClient.cs","lineNumber":337,"sourceCode":"        return statementResults;\n    }\n\n    private static void ValidateCloseResult(RemotePipelineResponse response)\n    {\n        foreach (var result in response.Results)\n        {\n            switch (result.Type)\n            {\n                case \"ok\":\n                    if (result.Response?.Type is not \"close\")\n                        throw new TursoException($\"Remote close returned unexpected response type: {result.Response?.Type}\");\n                    break;\n\n                case \"error\":\n                    throw CreateRemoteError(result.Error);\n\n                default:\n                    throw new TursoException($\"Remote close returned unexpected result type: {result.Type}\");\n            }\n        }\n    }\n\n    private static TursoException CreateRemoteError(RemoteError? error)\n    {\n        if (error is null)\n            return new TursoRemoteSqlException(\"Remote SQL execution failed.\");\n\n        return string.IsNullOrWhiteSpace(error.Code)\n            ? new TursoRemoteSqlException($\"Remote SQL execution failed: {error.Message}\")\n            : new TursoRemoteSqlException($\"Remote SQL execution failed: {error.Message} ({error.Code})\");\n    }\n\n    private void UpdateSession(RemotePipelineResponse response, bool closeAfter)\n    {\n        if (!string.IsNullOrWhiteSpace(response.BaseUrl))\n        {","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Data/TursoRemoteClient.cs#L319-L355","documentation":"While validating the response to a close request, the client found a top-level result entry whose type is neither \"ok\" nor \"error\". ValidateCloseResult iterates every entry in the close response, so any unknown type string aborts connection close.","triggerScenarios":"Closing/disposing a remote TursoConnection with an open session where a response entry's Type is outside ok/error -- for example a future entry kind the bindings do not recognize.","commonSituations":"Newer server emitting new entry types on close that older bindings reject; middleware injecting entries; custom /v2/pipeline implementations; the exception surfacing from Dispose in 'await using' blocks.","solutions":["Capture the raw close-response envelope and identify the unknown type string.","Upgrade the Turso.Data bindings to a version matching the server.","If an intermediary injects entries, take it off the pipeline route.","Make close failures non-fatal in disposal paths (see the close-safe finally pattern) while you upgrade."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await conn.CloseAsync(cancellationToken); }\ncatch (TursoException ex) when (ex.Message.Contains(\"Remote close returned unexpected result type\"))\n{\n    logger.LogWarning(ex, \"Unknown entry type in close response; upgrading bindings likely required\");\n}","preventionTips":["Upgrade Turso.Data bindings in lockstep with server upgrades.","Keep middleware from injecting entries into close responses.","Treat close/Dispose-time exceptions as diagnostic signals, not data failures -- separate the two in code.","Capture the raw close envelope when reporting the unknown type."],"tags":["turso","dotnet","remote","connection-close","protocol","response-type"],"backgroundTag":"unexpected-response-type","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}