{"record":{"id":"94ec159f633d139e","repo":"continuedev/continue","slug":"error-processing-bedrock-stream-error-message","errorCode":null,"errorMessage":"Error processing Bedrock stream: ${error.message}","messagePattern":"Error processing Bedrock stream: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/Bedrock.ts","lineNumber":566,"sourceCode":"                    function: {\n                      name: start.toolUse.name,\n                      arguments: undefined,\n                    },\n                  },\n                ],\n              },\n            });\n          }\n        }\n      }\n    } catch (error) {\n      if (error instanceof Error) {\n        if (\"code\" in error) {\n          throw new Error(\n            `AWS Bedrock stream error (${(error as any).code}): ${error.message}`,\n          );\n        }\n        throw new Error(`Error processing Bedrock stream: ${error.message}`);\n      }\n      throw new Error(\n        \"Error processing Bedrock stream: Unknown error occurred\",\n      );\n    }\n  }\n\n  completionNonStream(\n    body: CompletionCreateParamsNonStreaming,\n  ): Promise<Completion> {\n    throw new Error(\"Bedrock does not support completions API\");\n  }\n\n  completionStream(\n    body: CompletionCreateParamsStreaming,\n  ): AsyncGenerator<Completion> {\n    throw new Error(\"Bedrock does not support completions API\");\n  }","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/Bedrock.ts#L548-L584","documentation":"Thrown when the streaming loop in chatCompletionStream encounters an Error without a `code` property — i.e. a non-AWS error such as a JSON parse failure, a malformed SSE event, or a JS-level exception while decoding chunks. The original message is preserved so you can tell whether the stream data was malformed or something else broke.","triggerScenarios":"Bedrock returns a truncated or malformed event stream; the adapter tries to JSON.parse a partial/invalid chunk; a TextDecoder or generator iteration error occurs; any runtime Error lacking `code` is raised inside the try block of the stream consumer.","commonSituations":"Model output interrupted mid-generation (network drop, server-side truncation); proxy or load balancer buffering/corrupting chunked responses; version mismatch between adapter's expected event shape and the actual Bedrock response format.","solutions":["Inspect error.message: 'Unexpected token...' usually means a truncated/malformed chunk — retry the request.","If reproducible with one prompt, check for very large single chunks or content that breaks the adapter's parsing; update the openai-adapters package to the latest patch.","Test the same request with the AWS CLI (aws bedrock-runtime invoke-model-with-response-stream) to confirm whether the raw stream is healthy.","If a proxy sits between client and Bedrock, disable response buffering for streaming endpoints."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  for await (const chunk of api.chatCompletionStream(body)) { /* ... */ }\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Error processing Bedrock stream')) {\n    // malformed/truncated stream — safe to retry idempotently\n    return retryOnce();\n  }\n  throw e;\n}","preventionTips":["Disable proxy buffering for streaming endpoints.","Keep the openai-adapters package updated to match current Bedrock event formats.","Log error.message to distinguish parse failures from service errors."],"tags":["bedrock","streaming","parsing","runtime-error"],"backgroundTag":"malformed-stream-chunk","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}