{"record":{"id":"87371b3940e26f33","repo":"BerriAI/litellm","slug":"error-converting-to-valid-response-block-e-file","errorCode":null,"errorMessage":"Error converting to valid response block={e}. File an issue if litellm error - https://github.com/BerriAI/litellm/issues","messagePattern":"Error converting to valid response block=(.+?)\\. File an issue if litellm error - https://github\\.com/BerriAI/litellm/issues","errorType":"exception","errorClass":"BedrockError","httpStatus":422,"severity":"error","filePath":"litellm/llms/bedrock/chat/converse_transformation.py","lineNumber":2157,"sourceCode":"        data: dict | str,\n        messages: list,\n        encoding,\n    ) -> ModelResponse:\n        ## LOGGING\n        if logging_obj is not None:\n            logging_obj.post_call(\n                input=messages,\n                api_key=api_key,\n                original_response=response.text,\n                additional_args={\"complete_input_dict\": data},\n            )\n\n        json_mode: Final[bool | None] = optional_params.get(\"json_mode\", None)\n        ## RESPONSE OBJECT\n        try:\n            completion_response: Final = ConverseResponseBlock(**response.json())\n        except Exception as e:\n            raise BedrockError(\n                message=f\"Error converting to valid response block={e}. File an issue if litellm error - https://github.com/BerriAI/litellm/issues\",\n                status_code=422,\n            )\n\n        \"\"\"\n        Bedrock Response Object has optional message block\n\n        completion_response[\"output\"].get(\"message\", None)\n\n        A message block looks like this (Example 1):\n        \"output\": {\n            \"message\": {\n                \"role\": \"assistant\",\n                \"content\": [\n                    {\n                        \"text\": \"Is there anything else you'd like to talk about? Perhaps I can help with some economic questions or provide some information about economic concepts?\"\n                    }\n                ]","sourceCodeStart":2139,"sourceCodeEnd":2175,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/converse_transformation.py#L2139-L2175","documentation":"After a successful HTTP 200, the Bedrock Converse response JSON is validated into the typed ConverseResponseBlock model. Any mismatch — missing required fields, wrong types, or new AWS fields the installed LiteLLM schema does not know — raises BedrockError 422 with a message asking you to file an issue. The network call succeeded; this is a schema mismatch between AWS output and LiteLLM's response model.","triggerScenarios":"AWS ships a response containing fields, enum values, or block types absent from your LiteLLM version's ConverseResponseBlock; an error body reaching the success parser; a response mutated by a proxy or cross-region inference endpoint with a nonstandard envelope.","commonSituations":"Running an older LiteLLM against a newly updated Bedrock API; beta features (guardrail traces, performance configs, new tool result shapes) returning extra fields; the morning after an AWS rollout with a pinned litellm version.","solutions":["Upgrade LiteLLM to the latest release — response-block models are updated in patch releases as Bedrock adds fields","Capture response.text with a post-call logging hook to identify the offending field","If it persists on the latest version, file the issue at https://github.com/BerriAI/litellm/issues with the redacted payload","As a stopgap, pin calls to a Bedrock region/model combination that still returns the older schema"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.completion(model=\"bedrock/...\", messages=msgs)\nexcept BedrockError as e:\n    if e.status_code == 422 and \"Error converting to valid response block\" in str(e):\n        logger.error(\"Bedrock schema drift — update litellm; payload: %s\", captured_response_text)\n        raise DependencyOutdated(\"pip install -U litellm\") from e\n    raise","preventionTips":["Keep LiteLLM on recent releases when using newest Bedrock features","Subscribe to LiteLLM release notes for ConverseResponseBlock schema updates","Capture response bodies with logging hooks in staging to detect drift before prod"],"tags":["bedrock","converse","schema","pydantic","version-drift"],"backgroundTag":"schema-validation-failed","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}