{"record":{"id":"e2c9d217fa3e54c6","repo":"BerriAI/litellm","slug":"no-results-found-in-the-response-response","errorCode":null,"errorMessage":"No results found in the response={response}","messagePattern":"No results found in the response=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/rerank/transformation.py","lineNumber":104,"sourceCode":"        \"\"\"\n        _billed_units = RerankBilledUnits(**response.get(\"usage\", {\"search_units\": 1}))  # by default 1 search unit\n        _tokens: Final = RerankTokens(**response.get(\"usage\", {}))\n        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)\n\n        _results: list[RerankResponseResult] | None = None\n\n        bedrock_results: Final = response.get(\"results\")\n        if bedrock_results:\n            _results = [\n                RerankResponseResult(\n                    index=result.get(\"index\"),\n                    relevance_score=result.get(\"relevanceScore\"),\n                )\n                for result in bedrock_results\n            ]\n\n        if _results is None:\n            raise ValueError(f\"No results found in the response={response}\")\n\n        return RerankResponse(\n            id=response.get(\"id\") or str(uuid.uuid4()),\n            results=_results,\n            meta=rerank_meta,\n        )  # Return response\n","sourceCodeStart":86,"sourceCodeEnd":111,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/rerank/transformation.py#L86-L111","documentation":"After transforming the Bedrock rerank response, litellm expects response['results'] to be a non-empty list it can map to RerankResponseResult objects. If 'results' is missing, None, or empty, _results stays None and a ValueError('No results found in the response={response}') is raised, echoing the full response for diagnosis.","triggerScenarios":"A 200 response from bedrock-agent-runtime /rerank whose body lacks 'results' — usually caused by empty documents, query/document combos the model cannot score, or API changes/edge cases where Bedrock omits the field.","commonSituations":"Passing an empty documents list, whitespace-only queries, documents that truncate to empty strings, or intermediary proxies mangling the response body.","solutions":["Check the echoed response in the message: if results is absent/empty, inspect what you sent (non-empty query, non-empty documents).","Filter out empty-string documents and empty queries before calling rerank.","If documents were valid, retry once — occasional empty bodies indicate transient service issues.","Report reproducible empty-results responses to litellm/AWS with the payload shape."],"exampleFix":"# before\nresult = litellm.rerank(model=MODEL, query='', documents=['', 'a doc'])\n\n# after\ndocs = [d for d in documents if d and d.strip()]\nif not query.strip() or not docs:\n    return []  # nothing to rerank\nresult = litellm.rerank(model=MODEL, query=query, documents=docs)","handlingStrategy":"validation","validationCode":"def is_rerankable(query: str, documents: list) -> bool:\n    return bool(query and query.strip()) and bool(documents) and all(\n        (isinstance(d, str) and d.strip()) or (isinstance(d, dict) and d.get(\"text\", \"\").strip())\n        for d in documents\n    )","typeGuard":"def has_rerank_inputs(query: str, documents: list[str | dict]) -> bool:\n    return is_rerankable(query, documents)","tryCatchPattern":"try:\n    result = litellm.rerank(model=model, query=q, documents=docs)\nexcept ValueError as e:\n    if \"No results found\" in str(e):\n        log.warning(\"Empty rerank result; falling back to unranked documents\")\n        return docs  # graceful degradation\n    raise","preventionTips":["Filter empty/whitespace documents and queries before calling rerank.","Treat an empty result as a soft failure with a fallback ordering.","Log the echoed response to detect provider/proxy anomalies."],"tags":["bedrock","rerank","response-parsing","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}