{"record":{"id":"cf49fd6bd96dd9fd","repo":"tursodatabase/turso","slug":"remote-request-returned-unexpected-response-type","errorCode":null,"errorMessage":"Remote request returned unexpected response type: {result.Response.Type}","messagePattern":"Remote request returned unexpected response type: (.+?)","errorType":"exception","errorClass":"TursoException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoRemoteClient.cs","lineNumber":229,"sourceCode":"        }\n\n        return statement;\n    }\n\n    private static RemoteStatementResult ExtractExecuteResult(RemotePipelineResponse response)\n    {\n        if (response.Results.Count == 0)\n            throw new TursoException(\"Remote request returned no results.\");\n\n        var result = response.Results[0];\n        RemoteStatementResult statementResult;\n        switch (result.Type)\n        {\n            case \"ok\":\n                if (result.Response is null)\n                    throw new TursoException(\"Remote request returned an empty ok response.\");\n                if (result.Response.Type != \"execute\")\n                    throw new TursoException($\"Remote request returned unexpected response type: {result.Response.Type}\");\n                statementResult = result.Response.DeserializeResult<RemoteStatementResult>();\n                break;\n\n            case \"error\":\n                throw CreateRemoteError(result.Error);\n\n            default:\n                throw new TursoException($\"Remote request returned unexpected result type: {result.Type}\");\n        }\n\n        ValidateOptionalTrailingClose(response, \"Remote request\");\n        return statementResult;\n    }\n\n    private static IReadOnlyList<RemoteStatementResult> ExtractBatchResults(RemotePipelineResponse response, int expectedCount)\n    {\n        if (response.Results.Count == 0)\n            throw new TursoException(\"Remote batch returned no results.\");","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Data/TursoRemoteClient.cs#L211-L247","documentation":"The first pipeline result was ok, but its inner response object had a type other than \"execute\" (for example \"batch\" or \"close\"). The client submitted a single statement execution, so any other inner type means the reply does not correspond to the request that was sent.","triggerScenarios":"Remote TursoCommand execution where response.Results[0].Response.Type != \"execute\": the server answered with a batch-shaped or close-shaped payload, or responses were reordered/cross-wired.","commonSituations":"Server/client version drift changing the response envelope; a stateful session (baton) reused across connections that should have had separate sessions; middleware that caches or reorders pipeline responses; custom servers implementing /v2/pipeline incorrectly.","solutions":["Dump the raw response and confirm which inner type came back.","Give each TursoConnection its own connection string and lifecycle; never share or replay session state across connections.","Disable response caching on the pipeline route at any proxy layer.","Upgrade both server and Turso.Data bindings to matching releases.","Report with the raw envelope if current versions still mismatch."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return await cmd.ExecuteReaderAsync(cancellationToken); }\ncatch (TursoException ex) when (ex.Message.Contains(\"unexpected response type\"))\n{\n    logger.LogError(ex, \"Reply/request mismatch for {Sql} -- check session sharing and versions\", cmd.CommandText);\n    throw;\n}","preventionTips":["Give every TursoConnection its own lifecycle; never reuse connection objects or session state across logical sessions.","Disable response caching on the pipeline route at every proxy layer.","Keep server and bindings versions aligned.","When responses look crossed, capture the raw envelope before changing code."],"tags":["turso","dotnet","remote","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"}