tursodatabase/turso · error · TursoException

Remote batch did not return a result for step

Error message

Remote batch did not return a result for step {i}.

What it means

Inside a batch result, a step had neither an error nor a result: step_errors[i] and step_results[i] were both null. The protocol requires exactly one of the two per step, so the server omitted the outcome for statement i.

Solutions

  1. Identify which step index fails (the message includes i) and map it back to the TursoBatchCommand at that position; simplify that statement to find the trigger.
  2. Run the failing statement as a standalone command to see whether it produces a normal result outside a batch.
  3. Align server and bindings versions.
  4. If it reproduces on current versions, report the batch and the missing step index.
Defensive patterns

Strategy: try-catch

Try / catch

try { return await batch.ExecuteReaderAsync(cancellationToken); }
catch (TursoException ex) when (ex.Message.Contains("did not return a result for step"))
{
    logger.LogError(ex, "Batch step missing a result; message names the step index");
    throw;
}

Prevention

When it happens

Trigger: TursoBatch execution where the counts match but a specific step i has a null entry in step_results while its step_errors slot is also null.

Common situations: Server bugs that skip result materialization for certain statements (for example DDL or empty SQL inside a batch); schema drift between server and bindings; intermediaries nulling out fields.

Related errors


AI-assisted analysis of tursodatabase/turso@6c72522679 (2026-08-20). Data as JSON: /api/errors/90ade0e7085f3651. Report an issue: GitHub.

Appendix: source

Thrown at bindings/dotnet/src/Turso.Data/TursoRemoteClient.cs:320

    private static List<RemoteStatementResult> ExtractBatchStepResults(RemoteBatchResult batch, int expectedCount)
    {
        if (batch.StepErrors.Count != expectedCount || batch.StepResults.Count != expectedCount)
        {
            throw new TursoException(
                $"Remote batch returned an unexpected result shape: {batch.StepResults.Count} results, {batch.StepErrors.Count} errors, expected {expectedCount}.");
        }

        for (var i = 0; i < batch.StepErrors.Count; i++)
        {
            if (batch.StepErrors[i] is { } error)
                throw CreateRemoteError(error);
        }

        var statementResults = new List<RemoteStatementResult>(expectedCount);
        for (var i = 0; i < batch.StepResults.Count; i++)
        {
            var stepResult = batch.StepResults[i]
                             ?? throw new TursoException($"Remote batch did not return a result for step {i}.");
            statementResults.Add(stepResult);
        }

        return statementResults;
    }

    private static void ValidateCloseResult(RemotePipelineResponse response)
    {
        foreach (var result in response.Results)
        {
            switch (result.Type)
            {
                case "ok":
                    if (result.Response?.Type is not "close")
                        throw new TursoException($"Remote close returned unexpected response type: {result.Response?.Type}");
                    break;

                case "error":

View on GitHub (pinned to 6c72522679)