BerriAI/litellm · error · ValueError
No results found in the response={response}
Error message
No results found in the response={response} What it means
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.
Source
Thrown at litellm/llms/bedrock/rerank/transformation.py:104
"""
_billed_units = RerankBilledUnits(**response.get("usage", {"search_units": 1})) # by default 1 search unit
_tokens: Final = RerankTokens(**response.get("usage", {}))
rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)
_results: list[RerankResponseResult] | None = None
bedrock_results: Final = response.get("results")
if bedrock_results:
_results = [
RerankResponseResult(
index=result.get("index"),
relevance_score=result.get("relevanceScore"),
)
for result in bedrock_results
]
if _results is None:
raise ValueError(f"No results found in the response={response}")
return RerankResponse(
id=response.get("id") or str(uuid.uuid4()),
results=_results,
meta=rerank_meta,
) # Return response
View on GitHub (pinned to 6c2dcb801b)
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.
Example fix
# before
result = litellm.rerank(model=MODEL, query='', documents=['', 'a doc'])
# after
docs = [d for d in documents if d and d.strip()]
if not query.strip() or not docs:
return [] # nothing to rerank
result = litellm.rerank(model=MODEL, query=query, documents=docs) Defensive patterns
Strategy: validation
Validate before calling
def is_rerankable(query: str, documents: list) -> bool:
return bool(query and query.strip()) and bool(documents) and all(
(isinstance(d, str) and d.strip()) or (isinstance(d, dict) and d.get("text", "").strip())
for d in documents
) Type guard
def has_rerank_inputs(query: str, documents: list[str | dict]) -> bool:
return is_rerankable(query, documents) Try / catch
try:
result = litellm.rerank(model=model, query=q, documents=docs)
except ValueError as e:
if "No results found" in str(e):
log.warning("Empty rerank result; falling back to unranked documents")
return docs # graceful degradation
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Passing an empty documents list, whitespace-only queries, documents that truncate to empty strings, or intermediary proxies mangling the response body.
Related errors
- Missing required fields in the result={result}
- Unsupported image format: {image_format}. Supported formats:
- No supported extensions for MIME type: {mime_type}. Supporte
- Unexpected mistral completion response
- Invalid guardrailConfig={raw_guardrail_config}. Expected for
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/e2c9d217fa3e54c6.
Report an issue: GitHub.