{"record":{"id":"527157ed324f8c02","repo":"BerriAI/litellm","slug":"error-parsing-received-text-outputtext-error-e","errorCode":null,"errorMessage":"Error parsing received text={outputText}.\nError-{e}","messagePattern":"Error parsing received text=(.+?)\\.\nError-(.+?)","errorType":"exception","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py","lineNumber":383,"sourceCode":"            )\n\n        try:\n            if (\n                outputText is not None\n                and len(outputText) > 0\n                and hasattr(model_response.choices[0], \"message\")\n                and getattr(model_response.choices[0].message, \"tool_calls\", None) is None\n            ):\n                model_response.choices[0].message.content = outputText\n            elif (\n                hasattr(model_response.choices[0], \"message\")\n                and getattr(model_response.choices[0].message, \"tool_calls\", None) is not None\n            ):\n                pass\n            else:\n                raise Exception()\n        except Exception as e:\n            raise BedrockError(\n                message=f\"Error parsing received text={outputText}.\\nError-{e}\",\n                status_code=raw_response.status_code,\n            )\n\n        ## CALCULATING USAGE - bedrock returns usage in the headers\n        bedrock_input_tokens: Final = raw_response.headers.get(\"x-amzn-bedrock-input-token-count\", None)\n        bedrock_output_tokens: Final = raw_response.headers.get(\"x-amzn-bedrock-output-token-count\", None)\n\n        prompt_tokens: Final = int(bedrock_input_tokens or litellm.token_counter(messages=messages))\n\n        completion_tokens: Final = int(\n            bedrock_output_tokens\n            or litellm.token_counter(\n                text=model_response.choices[0].message.content,\n                count_response_tokens=True,\n            )\n        )\n","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py#L365-L401","documentation":"Assignment failure while writing outputText into the model response: the extracted text could not be set on choices[0].message.content because the response object lacked the expected shape, and the handler appends the parse exception for diagnosis.","triggerScenarios":"Thrown at litellm/llms/bedrock/chat/invoke_transformations/base_invoke_transformation.py:383 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check outputText for malformed or unexpected content from the model.","Retry the request; parsing failures can be transient.","Upgrade litellm if the provider response format changed."],"exampleFix":null,"handlingStrategy":"try-catch","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"}