{"record":{"id":"a550dda2addc1dd6","repo":"BerriAI/litellm","slug":"bedrock-event-stream-shape-could-not-be-loaded-fro-a550dd","errorCode":null,"errorMessage":"Bedrock event-stream shape could not be loaded from botocore. Ensure botocore is correctly installed.","messagePattern":"Bedrock event-stream shape could not be loaded from botocore\\. Ensure botocore is correctly installed\\.","errorType":"http","errorClass":"BedrockError","httpStatus":500,"severity":"critical","filePath":"litellm/llms/bedrock/common_utils.py","lineNumber":1288,"sourceCode":"                status_code = int(modeled_status)\n\n    return BedrockError(status_code=status_code, message=message)\n\n\nclass BedrockEventStreamDecoderBase:\n    \"\"\"\n    Base class for event stream decoding for Bedrock\n    \"\"\"\n\n    def __init__(self):\n        from botocore.parsers import EventStreamJSONParser\n\n        self.parser = EventStreamJSONParser()\n\n    def _parse_message_from_event(self, event) -> str | None:\n        response_stream_shape: Final = get_bedrock_response_stream_shape()\n        if response_stream_shape is None:\n            raise BedrockError(\n                status_code=500,\n                message=(\n                    \"Bedrock event-stream shape could not be loaded from botocore. \"\n                    \"Ensure botocore is correctly installed.\"\n                ),\n            )\n        response_dict: Final = event.to_response_dict()\n        parsed_response: Final = self.parser.parse(response_dict, response_stream_shape)\n\n        if response_dict[\"status_code\"] != 200:\n            raise build_bedrock_stream_error(response_dict, response_stream_shape)\n        if \"chunk\" in parsed_response:\n            chunk = parsed_response.get(\"chunk\")\n            if not chunk:\n                return None\n            return chunk.get(\"bytes\").decode()\n        else:\n            chunk = response_dict.get(\"body\")","sourceCodeStart":1270,"sourceCodeEnd":1306,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/common_utils.py#L1270-L1306","documentation":"Identical condition to the decoder variant in invoke_handler.py, raised from the shared base event-stream decoder in common_utils.py: get_bedrock_response_stream_shape() returned None, so litellm could not obtain the bedrock-runtime 'responseStream' shape from the installed botocore and cannot decode the AWS binary event-stream. Surface as BedrockError 500 with the fixed botocore-installation message.","triggerScenarios":"Any Bedrock streaming decode that goes through the base decoder when botocore is absent, incomplete (missing bedrock-runtime service model), or too old to contain the event-stream shape litellm looks up.","commonSituations":"Docker images stripping botocore service models, dependency downgrades in lockfiles, lambda layers with partial boto3 installs, or freshly added model families hitting this code path before botocore is upgraded.","solutions":["Install/upgrade a full botocore: pip install -U boto3 botocore.","Verify the service model exists: inspect botocore.loaders for bedrock-runtime service-2.json in the installed package.","If you must pin botocore, use a version that ships bedrock-runtime event-stream models (recent 1.3x+).","Repair corrupted installs with pip install --force-reinstall botocore."],"exampleFix":"# before (image installs botocore-core without service models)\npip install botocore-core\n\n# after\npip install -U boto3 botocore\npython -c \"from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape; print(get_bedrock_response_stream_shape())\"  # must not be None","handlingStrategy":"validation","validationCode":"from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape\nif get_bedrock_response_stream_shape() is None:\n    raise RuntimeError(\"botocore lacks bedrock-runtime event-stream model - run: pip install -U boto3 botocore\")","typeGuard":"def event_stream_shape_available() -> bool:\n    try:\n        from litellm.llms.bedrock.common_utils import get_bedrock_response_stream_shape\n        return get_bedrock_response_stream_shape() is not None\n    except Exception:\n        return False","tryCatchPattern":"from litellm.exceptions import BedrockError\ntry:\n    for chunk in litellm.completion(model=\"bedrock/<model>\", messages=msgs, stream=True):\n        pass\nexcept BedrockError as e:\n    if \"event-stream shape\" in str(e):\n        raise RuntimeError(\"Dependency fix required: pip install -U boto3 botocore\") from e\n    raise","preventionTips":["Run a dependency smoke test (stream one chunk) in container builds that use Bedrock streaming.","Never deploy stripped botocore packages; install full boto3.","Alert on botocore downgrades in lockfile diffs."],"tags":["aws","bedrock","botocore","dependency","streaming"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}