{"record":{"id":"6e63b6d257f6e098","repo":"tursodatabase/turso","slug":"describe-execution-failed-6e63b6","errorCode":null,"errorMessage":"Describe execution failed","messagePattern":"Describe execution failed","errorType":"exception","errorClass":"TursoServerlessException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Serverless.Client/TursoSession.cs","lineNumber":54,"sourceCode":"    internal async Task<TursoStatementDescription> DescribeAsync(string sql, TimeSpan? queryTimeout, CancellationToken cancellationToken)\n    {\n        var request = new HranaPipelineRequest\n        {\n            Baton = _baton,\n            Requests =\n            [\n                new HranaPipelineRequestItem { Type = \"describe\", Sql = sql },\n                new HranaPipelineRequestItem { Type = \"get_autocommit\" },\n            ],\n        };\n\n        var response = await RunPipelineAsync(request, queryTimeout, cancellationToken).ConfigureAwait(false);\n\n        if (response.Results is [var result, ..])\n        {\n            if (result.Type == \"error\")\n            {\n                throw new TursoServerlessException(result.Error?.Message ?? \"Describe execution failed\", result.Error?.Code);\n            }\n\n            if (result.Response is { Type: \"describe\", Result: { } resultElement })\n            {\n                var describe = resultElement.Deserialize<HranaDescribeResult>(new JsonSerializerOptions(JsonSerializerDefaults.Web));\n                if (describe is not null)\n                {\n                    return new TursoStatementDescription(\n                        parameterNames: describe.Params?.Select(static p => p.Name ?? \"\").ToArray() ?? [],\n                        columns: describe.Cols?.Select(static c => c.Name ?? \"\").ToArray() ?? [],\n                        columnTypes: describe.Cols?.Select(static c => c.Decltype ?? \"\").ToArray() ?? [],\n                        isExplain: describe.IsExplain,\n                        isReadonly: describe.IsReadonly);\n                }\n            }\n        }\n\n        throw new TursoServerlessException(\"Unexpected describe response\");","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Serverless.Client/TursoSession.cs#L36-L72","documentation":"PrepareAsync sends a Hrana pipeline containing a describe request. If the first pipeline result comes back with type \"error\", the client wraps it in TursoServerlessException using the server's message — and this literal text only when the server error carried no message at all. The underlying cause is almost always the SQL itself failing to describe.","triggerScenarios":"Preparing a statement with a syntax error, an unknown table/column, or a malformed statement: session.PrepareAsync(\"SELCT 1\") or a query referencing a table that does not exist in the target database.","commonSituations":"Schema drift between local and remote databases; migrations not applied to the Turso database being addressed; typos in dynamically-built SQL strings.","solutions":["Run the same statement in the turso CLI (turso db shell) against the same database to get the full server error","Check that every table/column referenced exists on the target database, not just locally","If the message is the generic fallback, log the full response body and update the client so the server message propagates","For dynamic SQL, validate table/column names against the schema before preparing"],"exampleFix":"// before\nvar desc = await session.PrepareAsync($\"SELECT {userColumn} FROM {userTable}\");\n\n// after\n// verify identifiers exist first\nvar tables = await session.ExecuteAsync(\"SELECT name FROM sqlite_master WHERE type='table'\");\nvar desc = await session.PrepareAsync($\"SELECT {userColumn} FROM {userTable}\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var desc = await session.PrepareAsync(sql, ct); } catch (TursoServerlessException ex) { log.Error($\"prepare failed [{ex.Code}]: {ex.Message}; sql={sql}\"); throw; }","preventionTips":["Lint generated SQL against the live schema before prepare","Keep schema migrations applied to the target database before deploying dependent code","Log the SQL text alongside prepare failures — the fallback message carries no detail"],"tags":["csharp","dotnet","hrana-protocol","prepare","sql-syntax"],"backgroundTag":"sql-prepare-error","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}