{"record":{"id":"a77072427cecf528","repo":"BerriAI/litellm","slug":"error-setting-response-content-e-response-co","errorCode":null,"errorMessage":"Error setting response content: {e}. Response: {completion_response}","messagePattern":"Error setting response content: (.+?)\\. Response: (.+?)","errorType":"exception","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_transformations/amazon_twelvelabs_pegasus_transformation.py","lineNumber":239,"sourceCode":"        message_content: Final = completion_response.get(\"message\", \"\")\n\n        # Extract finish reason and map to LiteLLM format\n        finish_reason_raw: Final = completion_response.get(\"finishReason\", \"stop\")\n        finish_reason: Final = map_finish_reason(finish_reason_raw)\n\n        # Set the response content\n        try:\n            if (\n                message_content\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 = message_content\n                model_response.choices[0].finish_reason = finish_reason\n            else:\n                raise Exception(\"Unable to set message content\")\n        except Exception as e:\n            raise BedrockError(\n                message=f\"Error setting response content: {e}. Response: {completion_response}\",\n                status_code=raw_response.status_code,\n            )\n\n        # Calculate usage from 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":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_transformations/amazon_twelvelabs_pegasus_transformation.py#L221-L257","documentation":"Assignment failure while writing the extracted message content into model_response.choices[0].message.content: the response object shape did not accept the content (missing message attribute or unexpected structure), surfacing both the error and the parsed response for diagnosis.","triggerScenarios":"Thrown at litellm/llms/bedrock/chat/invoke_transformations/amazon_twelvelabs_pegasus_transformation.py:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect completion_response to see what the provider actually returned.","Verify the request matches the Pegasus model's expected input format.","Upgrade litellm if the response schema changed upstream."],"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-23T08:17:48.524Z"}