{"record":{"id":"f060e26df9d55c3b","repo":"tursodatabase/turso","slug":"missing-batch-result-in-pipeline-response","errorCode":null,"errorMessage":"missing batch result in pipeline response","messagePattern":"missing batch result in pipeline response","errorType":"exception","errorClass":"DatabaseError","httpStatus":null,"severity":"error","filePath":"serverless/javascript/src/session.ts","lineNumber":616,"sourceCode":"\n    let response: PipelineResponse;\n    try {\n      response = await executePipeline(this.httpContext(queryOptions), request, this.createAbortSignal(queryOptions));\n    } catch (e) {\n      this.baton = null;\n      this.autocommit = true;\n      throw e;\n    }\n\n    this.baton = response.baton;\n    if (response.base_url) {\n      this.baseUrl = normalizeUrl(response.base_url);\n    }\n    this.updateAutocommit(response);\n\n    const first = response.results?.[0];\n    if (!first) {\n      throw new DatabaseError('missing batch result in pipeline response');\n    }\n    if (first.type === 'error') {\n      throw new DatabaseError(first.error?.message || 'Batch execution failed', first.error?.code);\n    }\n    if (first.response?.type !== 'batch') {\n      throw new DatabaseError(`expected batch result in pipeline response, got ${first.response?.type}`);\n    }\n    const batchResult = first.response.result as BatchResultData | undefined;\n    const stepResults = batchResult?.step_results;\n    const stepErrors = batchResult?.step_errors;\n    if (\n      !Array.isArray(stepResults) ||\n      !Array.isArray(stepErrors) ||\n      stepResults.length !== steps.length ||\n      stepErrors.length !== steps.length\n    ) {\n      throw new DatabaseError('batch response does not have one result and one error per step');\n    }","sourceCodeStart":598,"sourceCodeEnd":634,"githubUrl":"https://github.com/tursodatabase/turso/blob/c1e59287258d99b309e362a63f48822256e2f65f/serverless/javascript/src/session.ts#L598-L634","documentation":"The serverless session sends a batch as a pipeline request and expects the first pipeline result to contain the batch response. If the response has no results at all, the protocol contract is violated (server error, proxy interference, or protocol mismatch), so batch() throws a DatabaseError rather than returning garbage.","triggerScenarios":"Calling session.batch() and receiving a pipeline response whose results array is empty or undefined — typically a server-side failure, an incompatible server version, or a truncated/intercepted HTTP response.","commonSituations":"Hitting the database through a proxy/load balancer that rewrites responses, pointing the client at a non-Turso or outdated endpoint, server crashes mid-pipeline.","solutions":["Log the raw HTTP response body to see what the server actually returned.","Upgrade the @tursodatabase/serverless client and server to matching versions.","Verify baseUrl points at a genuine Turso HTTP endpoint and no proxy strips the body.","Retry the batch; if persistent, report with the raw response payload."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"null","typeGuard":null,"tryCatchPattern":"try { await session.batch(stmts); } catch (e) { if (e instanceof DatabaseError && e.message === 'missing batch result in pipeline response') { /* log raw response, retry once, then fail */ } else throw e; }","preventionTips":["Keep client and server versions in lockstep.","Avoid HTTP proxies/rewriters between client and Turso endpoint.","Log raw pipeline responses when debugging protocol issues."],"tags":["serverless","protocol","batch","network"],"backgroundTag":"malformed-server-response","analyzedSha":"c1e59287258d99b309e362a63f48822256e2f65f","analyzedAt":"2026-08-31T11:17:35.598Z","contentChangedAt":"2026-08-31T11:17:35.598Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}