{"record":{"id":"a67df0aafb57c05f","repo":"BerriAI/litellm","slug":"err-response-text-a67df0","errorCode":null,"errorMessage":"{err.response.text}","messagePattern":"\\{err\\.response\\.text\\}","errorType":"exception","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/rerank/handler.py","lineNumber":117,"sourceCode":"            return self.arerank(\n                prepared_request,\n                timeout=timeout,\n                client=client if client is not None and isinstance(client, AsyncHTTPHandler) else None,\n            )\n\n        if client is None or not isinstance(client, HTTPHandler):\n            client = _get_httpx_client()\n        try:\n            response: Final = client.post(\n                url=prepared_request[\"endpoint_url\"],\n                headers=dict(prepared_request[\"prepped\"].headers),\n                data=prepared_request[\"body\"],\n                timeout=timeout,\n            )\n            response.raise_for_status()\n        except httpx.HTTPStatusError as err:\n            error_code: Final = err.response.status_code\n            raise BedrockError(status_code=error_code, message=err.response.text)\n        except httpx.TimeoutException:\n            raise BedrockError(status_code=408, message=\"Timeout error occurred.\")\n\n        logging_obj.post_call(\n            original_response=response.text,\n            api_key=\"\",\n        )\n\n        response_json: Final = response.json()\n\n        return BedrockRerankConfig()._transform_response(response_json)\n\n    def _prepare_request(\n        self,\n        model: str,\n        api_base: str | None,\n        extra_headers: dict | None,\n        data: dict,","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/rerank/handler.py#L99-L135","documentation":"Synchronous Bedrock rerank POST returned non-2xx; the httpx.HTTPStatusError is re-raised as BedrockError with the upstream status code and raw response body ({err.response.text}). This is the sync twin of the async guard and surfaces the bedrock-agent-runtime error JSON verbatim.","triggerScenarios":"litellm.rerank(model='bedrock/<rerank-model>', ...) hitting ValidationException (bad params), ThrottlingException (429), AccessDeniedException (403), or ResourceNotFoundException (unknown model).","commonSituations":"Model access not enabled for the rerank model in the chosen region, oversized document lists, wrong model ID format, missing IAM permission on bedrock-agent-runtime.","solutions":["Parse the message body for the AWS error code and fix the named field/permission.","Confirm the rerank model ID and region; enable model access in the Bedrock console.","For 429, back off and retry; reduce requests per second.","Validate documents (non-empty strings/dicts) before the call."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = litellm.rerank(model=model, query=q, documents=docs)\nexcept BedrockError as e:\n    if e.status_code == 400:\n        raise InvalidRerankRequest(e.message) from e  # body has AWS ValidationException detail\n    if e.status_code == 429:\n        backoff_and_retry()\n    raise","preventionTips":["Sanitize query/documents before calling rerank.","Keep the AWS error body in logs — it pinpoints the offending field.","Only retry 429/5xx statuses."],"tags":["bedrock","rerank","http-status","api-error"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}