{"record":{"id":"05eb51d5dc043340","repo":"BerriAI/litellm","slug":"error-message-05eb51","errorCode":null,"errorMessage":"{error_message}","messagePattern":"\\{error_message\\}","errorType":"http","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/chat/invoke_agent/transformation.py","lineNumber":245,"sourceCode":"        try:\n            response_dict: Final = event.to_response_dict()\n            verbose_logger.debug(\"Response dict: %s\", response_dict)\n\n            # Use the same response shape parsing as the existing decoder\n            parsed_response: Final = parser.parse(response_dict, self._get_response_stream_shape())\n            verbose_logger.debug(\"Parsed response: %s\", parsed_response)\n\n            if response_dict[\"status_code\"] != 200:\n                decoded_body: Final = response_dict[\"body\"].decode()\n                if isinstance(decoded_body, dict):\n                    error_message = decoded_body.get(\"message\")\n                elif isinstance(decoded_body, str):\n                    error_message = decoded_body\n                else:\n                    error_message = \"\"\n                exception_status: Final = response_dict[\"headers\"].get(\":exception-type\")\n                error_message = exception_status + \" \" + error_message\n                raise BedrockError(\n                    status_code=response_dict[\"status_code\"],\n                    message=(json.dumps(error_message) if isinstance(error_message, dict) else error_message),\n                )\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                return chunk.decode()\n\n        except Exception as e:\n            verbose_logger.debug(\"Error parsing message from event: %s\", e)\n            return None","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/bedrock/chat/invoke_agent/transformation.py#L227-L263","documentation":"For InvokeAgent responses with non-200 status, the body is decoded and combined with the ':exception-type' response header (prepended to the message) into a BedrockError preserving the upstream status code. The message may be JSON-encoded text when the body was an object, so the AWS error code appears as an 'exceptionType message' string.","triggerScenarios":"404 when the agent id or alias id no longer exists; 403 when the caller lacks permission on the agent alias; 429 throttling; 400 for invalid sessionId or memory configuration; accessDeniedException on cross-account invocations.","commonSituations":"Agent re-created or re-deployed so the alias id changed; IAM role missing bedrock:InvokeModel on the agent alias ARN; session id reuse across concurrent invocations violating constraints; expired alias after agent deletion.","solutions":["Read the exception-type prefix in the message for the AWS error code and map it to the specific fix","Confirm the agent id + alias id pair still exists (console: Agents → Aliases) and re-copy them","Grant bedrock:InvokeModel on the agent alias ARN in IAM when seeing 403","For 429 configure Router retries/fallbacks; for 400 check sessionId and memory parameters"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from litellm.exceptions import BedrockError\n\ntry:\n    resp = litellm.completion(model=f\"agent/{AGENT_ID}/{ALIAS_ID}\", messages=msgs)\nexcept BedrockError as e:\n    reason = str(e)  # ':exception-type' prefix + AWS message\n    if e.status_code == 404:\n        raise ConfigError(f\"Agent/alias not found — re-check ids: {reason}\") from e\n    if e.status_code == 403:\n        raise PermissionError(f\"Grant bedrock:InvokeModel on the alias ARN: {reason}\") from e\n    if e.status_code == 429:\n        time.sleep(2)\n        resp = litellm.completion(model=f\"agent/{AGENT_ID}/{ALIAS_ID}\", messages=msgs)\n    else:\n        raise","preventionTips":["Treat agent/alias ids as config that can drift — revalidate after agent re-deploys","Automate alias ARN lookups instead of hardcoding ids","Alert on 404s as a signal the alias lifecycle changed"],"tags":["bedrock","invoke-agent","http-status","aws","iam"],"backgroundTag":"http-error-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}