{"record":{"id":"48c5a9eb45ed9d18","repo":"BerriAI/litellm","slug":"str-e-48c5a9","errorCode":null,"errorMessage":"{str(e)}","messagePattern":"\\{str\\(e\\)\\}","errorType":"exception","errorClass":"BedrockError","httpStatus":500,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_handler.py","lineNumber":235,"sourceCode":"            decoder = AWSEventStreamDecoder(model=model, json_mode=json_mode)\n            completion_stream = decoder.aiter_bytes(response.aiter_bytes(chunk_size=stream_chunk_size))\n\n        # LOGGING\n        logging_obj.post_call(\n            input=messages,\n            api_key=\"\",\n            original_response=\"first stream response received\",\n            additional_args={\"complete_input_dict\": data},\n        )\n\n        return completion_stream\n    except httpx.HTTPStatusError as err:\n        error_code: Final = err.response.status_code\n        raise BedrockError(status_code=error_code, message=err.response.text)\n    except httpx.TimeoutException:\n        raise BedrockError(status_code=408, message=\"Timeout error occurred.\")\n    except Exception as e:\n        raise BedrockError(status_code=500, message=str(e))\n\n\ndef make_sync_call(\n    client: HTTPHandler | None,\n    api_base: str,\n    headers: dict,\n    data: str,\n    signed_json_body: bytes | None,\n    model: str,\n    messages: list,\n    logging_obj: Logging,\n    fake_stream: bool = False,\n    json_mode: bool | None = False,\n    bedrock_invoke_provider: litellm.BEDROCK_INVOKE_PROVIDERS_LITERAL | None = None,\n    stream_chunk_size: int | None = None,\n):\n    try:\n        if client is None:","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_handler.py#L217-L253","documentation":"Final catch-all in the async streaming maker: any exception other than httpx.HTTPStatusError and httpx.TimeoutException — connection errors, DNS failures, SSL problems, unexpected payload types — is re-raised as BedrockError 500 with str(e) as the message. The 500 is synthetic: it was generated by LiteLLM's wrapper, not reported by AWS.","triggerScenarios":"httpx.ConnectError or DNS resolution failure reaching bedrock.<region>.amazonaws.com; TLS certificate verification errors from missing CA bundles; protocol errors during stream setup; bugs in upstream parsing surfacing as generic exceptions.","commonSituations":"Containers or CI without egress routes/DNS to AWS; custom CA environments where cert verification fails; network policy changes mid-deployment; air-gapped clusters suddenly asked to call Bedrock.","solutions":["Enable verbose logging and read the embedded str(e) — it names the real underlying exception","Verify basic connectivity from the same environment: curl https://bedrock.<region>.amazonaws.com","Fix DNS, proxy, or CA-certificate issues revealed by the message rather than retrying blindly","For genuinely transient causes, retry on status 500 with capped attempts"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import socket\n\n# cheap pre-flight: can we resolve and reach the bedrock endpoint?\nregion = \"us-west-2\"\ntry:\n    socket.create_connection((f\"bedrock.{region}.amazonaws.com\", 443), timeout=5)\nexcept OSError as e:\n    raise RuntimeError(f\"No network path to Bedrock in {region}: {e}\")\n\nresp = await litellm.acompletion(model=\"bedrock/...\", messages=msgs, stream=True)","typeGuard":null,"tryCatchPattern":"try:\n    stream = await litellm.acompletion(model=\"bedrock/...\", messages=msgs, stream=True)\nexcept BedrockError as e:\n    if e.status_code == 500:\n        logger.error(\"Wrapped client failure (500 is synthetic): %s\", e.message)  # e.message holds str(orig)\n        if is_transient_network_error(e.message):\n            await asyncio.sleep(2)\n            stream = await litellm.acompletion(model=\"bedrock/...\", messages=msgs, stream=True)\n        else:\n            raise\n    else:\n        raise","preventionTips":["Verify DNS/egress to amazonaws.com from the runtime environment before deploying","Install full CA bundles in custom-cert environments","Treat synthetic 500s as client-environment problems until proven otherwise"],"tags":["bedrock","invoke","streaming","network","catch-all"],"backgroundTag":"internal-server-error","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}