{"record":{"id":"3bf7e267d39cae2f","repo":"BerriAI/litellm","slug":"bad-response-code-expected-200-response-dict","errorCode":null,"errorMessage":"Bad response code, expected 200: {response_dict}","messagePattern":"Bad response code, expected 200: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/sagemaker/common_utils.py","lineNumber":207,"sourceCode":"                yield None\n            except Exception as e:\n                verbose_logger.error(\"Final error parsing accumulated JSON: %s\", e)\n\n    def _parse_message_from_event(self, event) -> str | None:\n        response_stream_shape: Final = get_sagemaker_response_stream_shape()\n        if response_stream_shape is None:\n            raise SagemakerError(\n                status_code=500,\n                message=(\n                    \"SageMaker 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 ValueError(f\"Bad response code, expected 200: {response_dict}\")\n\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\")\n            if not chunk:\n                return None\n\n            return chunk.decode()\n","sourceCodeStart":189,"sourceCodeEnd":220,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/sagemaker/common_utils.py#L189-L220","documentation":"Response guard in the SageMaker event-stream decoder: an invocation response arrived whose status/payload is not a 200-style success, and the accumulated response_dict is echoed so the caller can see what the endpoint returned.","triggerScenarios":"Triggered when the SageMaker endpoint returns a response code other than 200.","commonSituations":"See trigger scenarios.","solutions":["The SageMaker endpoint returned a non-200 code; inspect response_dict for details.","Check endpoint health and request payload."],"exampleFix":"# log response_dict and check the endpoint in the AWS console.","handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}