{"record":{"id":"28a3d7f282e14879","repo":"BerriAI/litellm","slug":"err-response-text-28a3d7","errorCode":null,"errorMessage":"err.response.text","messagePattern":"err\\.response\\.text","errorType":"http","errorClass":"BedrockError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/rerank/handler.py","lineNumber":47,"sourceCode":"    async def arerank(\n        self,\n        prepared_request: BedrockPreparedRequest,\n        timeout: float | httpx.Timeout | None = None,\n        client: AsyncHTTPHandler | None = None,\n    ):\n        if client is None:\n            client = get_async_httpx_client(llm_provider=litellm.LlmProviders.BEDROCK)\n        try:\n            response: Final = await 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        return BedrockRerankConfig()._transform_response(response.json())\n\n    def rerank(\n        self,\n        model: str,\n        query: str,\n        documents: list[str | dict[str, Any]],\n        optional_params: dict,\n        logging_obj: LitellmLogging,\n        top_n: int | None = None,\n        rank_fields: list[str] | None = None,\n        return_documents: bool | None = True,\n        max_chunks_per_doc: int | None = None,\n        _is_async: bool | None = False,\n        timeout: float | httpx.Timeout | None = None,","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/rerank/handler.py#L29-L65","documentation":"Async Bedrock rerank POST returned non-2xx; httpx.HTTPStatusError from raise_for_status() is converted to BedrockError carrying the upstream status code and raw body (err.response.text). The body typically holds the bedrock-agent-runtime error JSON, e.g. ValidationException for a bad query/documents payload or AccessDeniedException for missing permissions.","triggerScenarios":"await litellm.rerank(model='bedrock/...') with malformed documents, too many documents exceeding the service limit, model access not enabled, or missing bedrock:InvokeModel on the agent-runtime rerank endpoint.","commonSituations":"Passing an unsupported model for rerank (only Amazon Rerank / Cohere rerank models serve this endpoint), empty query, documents exceeding size/count limits, IAM role without bedrock-agent-runtime access.","solutions":["Read the BedrockError message body — it names the AWS exception (ValidationException etc.) and field at fault.","Use a rerank-capable model (e.g. 'bedrock/amazon.rerank-v1:0' / 'bedrock/cohere.rerank-v3-5:0').","Trim documents to the service limits and ensure query/documents are non-empty strings.","Grant IAM bedrock:InvokeModel on the bedrock-agent-runtime rerank resource and enable model access."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await litellm.rerank(model=model, query=q, documents=docs, timeout=120)\nexcept BedrockError as e:\n    if e.status_code == 429 and attempt < MAX:\n        await asyncio.sleep(2 ** attempt + random.random())\n        continue\n    raise","preventionTips":["Validate documents (non-empty strings/dicts) before rerank calls.","Use only rerank-capable Bedrock models and enable access in the console.","Carry the raw error body into logs for AWS exception codes."],"tags":["bedrock","rerank","http-status","api-error","async"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}