{"record":{"id":"7792ef77b4f9ff77","repo":"earendil-works/pi","slug":"bedrock-stream-ended-without-a-stop-reason","errorCode":null,"errorMessage":"Bedrock stream ended without a stop reason","messagePattern":"Bedrock stream ended without a stop reason","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/api/bedrock-converse-stream.ts","lineNumber":318,"sourceCode":"\t\t\t\t} else if (item.internalServerException) {\n\t\t\t\t\tthrow item.internalServerException;\n\t\t\t\t} else if (item.modelStreamErrorException) {\n\t\t\t\t\tthrow item.modelStreamErrorException;\n\t\t\t\t} else if (item.validationException) {\n\t\t\t\t\tthrow item.validationException;\n\t\t\t\t} else if (item.throttlingException) {\n\t\t\t\t\tthrow item.throttlingException;\n\t\t\t\t} else if (item.serviceUnavailableException) {\n\t\t\t\t\tthrow item.serviceUnavailableException;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (options.signal?.aborted) {\n\t\t\t\tthrow new Error(\"Request was aborted\");\n\t\t\t}\n\n\t\t\tif (output.stopReason === \"pending\") {\n\t\t\t\tthrow new Error(\"Bedrock stream ended without a stop reason\");\n\t\t\t}\n\t\t\tif (output.stopReason === \"error\" || output.stopReason === \"aborted\") {\n\t\t\t\tthrow new Error(output.errorMessage || \"An unknown error occurred\");\n\t\t\t}\n\n\t\t\t// A stream can settle without stopping every block, so finalize here too.\n\t\t\tfor (const block of output.content) finalizeStreamingBlock(block as Block);\n\t\t\tstream.push({ type: \"done\", reason: output.stopReason, message: output });\n\t\t\tstream.end();\n\t\t} catch (error) {\n\t\t\tfor (const block of output.content) {\n\t\t\t\tfinalizeStreamingBlock(block as Block);\n\t\t\t}\n\t\t\toutput.stopReason = options.signal?.aborted ? \"aborted\" : \"error\";\n\t\t\toutput.errorMessage = formatBedrockError(error);\n\t\t\tif (output.stopReason === \"error\") {\n\t\t\t\tappendBedrockFailureDiagnostic(output, error, responseRequestId);\n\t\t\t}","sourceCodeStart":300,"sourceCodeEnd":336,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/ai/src/api/bedrock-converse-stream.ts#L300-L336","documentation":"Error \"Bedrock stream ended without a stop reason\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/ai/src/api/bedrock-converse-stream.ts:318 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry; inspect the final ConverseStream events for an error entry."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}