{"record":{"id":"80bf8b14834c08ca","repo":"apache/seatunnel","slug":"bedrock-mantle-stream-ended-abnormally-message","errorCode":null,"errorMessage":"Bedrock Mantle stream ended abnormally: {message}","messagePattern":"Bedrock Mantle stream ended abnormally: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"seatunnel-cli/seatunnel_cli/llm_provider.py","lineNumber":1244,"sourceCode":"                if item_type == \"function_call\" and current_tool_id:\n                    yield {\"type\": \"tool_stop\", \"tool_use_id\": current_tool_id}\n                    current_tool_id = None\n                elif item_type == \"reasoning\":\n                    yield {\n                        \"type\": \"mantle_responses_item\",\n                        \"item\": self._dump_item(item),\n                    }\n            elif etype == \"response.refusal.done\":\n                refusal = getattr(event, \"refusal\", \"\") or \"\"\n                raise RuntimeError(\n                    f\"Bedrock Mantle model refused the request: {refusal}\")\n            elif etype in (\"response.failed\", \"response.incomplete\",\n                           \"response.error\", \"error\"):\n                resp = getattr(event, \"response\", None)\n                self._raise_on_terminal_status(resp) if resp is not None \\\n                    else None\n                message = getattr(event, \"message\", \"\") or etype\n                raise RuntimeError(\n                    f\"Bedrock Mantle stream ended abnormally: {message}\")\n            elif etype == \"response.completed\":\n                self._raise_on_terminal_status(getattr(event, \"response\", None))\n                yield {\n                    \"type\": \"message_stop\",\n                    \"stop_reason\": \"tool_use\" if saw_tool_use else \"end_turn\",\n                }\n\n\n# ─── OrcaRouter Provider ───\n\nclass OrcaRouterProvider(OpenAIProvider):\n    \"\"\"OrcaRouter AI gateway provider (OpenAI Chat Completions API).\n\n    OrcaRouter is an OpenAI-compatible gateway that exposes many models (and\n    provider/model routing namespaces) behind one endpoint. Models are\n    addressed as ``provider/model``, e.g. ``orcarouter/auto`` routes and\n    grades automatically. Defaults to the ``orcarouter/auto`` model, which","sourceCodeStart":1226,"sourceCodeEnd":1262,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-cli/seatunnel_cli/llm_provider.py#L1226-L1262","documentation":"Raised by chat_stream() when the Mantle Responses stream terminates with a failure-class event (response.failed, response.incomplete, response.error, or a generic error) that carries no response object for _raise_on_terminal_status to interpret. The event's message (or the event type itself) is embedded in the RuntimeError.","triggerScenarios":"Streaming via chat_stream() and receiving etype in {\"response.failed\",\"response.incomplete\",\"response.error\",\"error\"} where event.response is None, so the fallback message = getattr(event, \"message\", \"\") or etype path raises.","commonSituations":"Transient Bedrock service errors during generation; malformed requests rejected mid-stream; throttling or internal model errors surfaced only as stream events.","solutions":["Retry the request, ideally with exponential backoff, since many stream failures are transient","Log the embedded message/etype and check AWS Bedrock service health and quotas","Catch the RuntimeError around stream iteration and restart the stream from the last received chunk"],"exampleFix":"// before\nfor chunk in provider.chat_stream(messages):\n    process(chunk)\n// after\nfor attempt in range(3):\n    try:\n        for chunk in provider.chat_stream(messages):\n            process(chunk)\n        break\n    except RuntimeError as e:\n        if \"ended abnormally\" in str(e) and attempt < 2:\n            time.sleep(2 ** attempt)\n            continue\n        raise","handlingStrategy":"retry","validationCode":"if not provider:\n    raise ValueError(\"provider must be initialized before streaming\")","typeGuard":"def is_abnormal_stream_end(e: BaseException) -> bool:\n    return isinstance(e, RuntimeError) and \"ended abnormally\" in str(e)","tryCatchPattern":"for attempt in range(3):\n    try:\n        for chunk in provider.chat_stream(messages):\n            handle(chunk)\n        break\n    except RuntimeError as e:\n        if \"ended abnormally\" in str(e) and attempt < 2:\n            time.sleep(2 ** attempt)\n        else:\n            raise","preventionTips":["Always iterate provider streams inside a retry loop with backoff","Persist received chunks so streams can be resumed after abnormal termination","Monitor Bedrock service health/quotas when failures cluster"],"tags":["llm","bedrock","streaming","network"],"backgroundTag":"http-request-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}