{"record":{"id":"eead51e2c267cbe8","repo":"BerriAI/litellm","slug":"no-results-found-in-the-response-response-eead51","errorCode":null,"errorMessage":"No results found in the response={response}","messagePattern":"No results found in the response=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/together_ai/rerank/transformation.py","lineNumber":29,"sourceCode":"    RerankBilledUnits,\n    RerankResponse,\n    RerankResponseDocument,\n    RerankResponseMeta,\n    RerankResponseResult,\n    RerankTokens,\n)\n\n\nclass TogetherAIRerankConfig:\n    def _transform_response(self, response: dict) -> RerankResponse:\n        _billed_units: Final = RerankBilledUnits(**response.get(\"usage\", {}))\n        _tokens: Final = RerankTokens(**response.get(\"usage\", {}))\n        rerank_meta: Final = RerankResponseMeta(billed_units=_billed_units, tokens=_tokens)\n\n        _results: Final[list[dict] | None] = response.get(\"results\")\n\n        if _results is None:\n            raise ValueError(f\"No results found in the response={response}\")\n\n        rerank_results: Final[list[RerankResponseResult]] = []\n\n        for result in _results:\n            # Validate required fields exist\n            if not all(key in result for key in [\"index\", \"relevance_score\"]):\n                raise ValueError(f\"Missing required fields in the result={result}\")\n\n            # Get document data if it exists\n            document_data = result.get(\"document\", {})\n            document = RerankResponseDocument(text=str(document_data.get(\"text\", \"\"))) if document_data else None\n\n            # Create typed result\n            rerank_result = RerankResponseResult(\n                index=int(result[\"index\"]),\n                relevance_score=float(result[\"relevance_score\"]),\n            )\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/together_ai/rerank/transformation.py#L11-L47","documentation":"After a successful TogetherAI rerank HTTP call, LiteLLM parses the JSON body and expects a 'results' key. If response.get('results') is None — the key is absent or explicitly null — _transform_response raises ValueError with the whole response embedded, because it cannot construct a RerankResponse without results. This indicates a malformed or unexpected Together payload rather than an HTTP failure (that would have raised earlier).","triggerScenarios":"Together returns 200 with a body lacking 'results' (e.g. an error object, empty response, or an API shape change); a proxy/interceptor rewrites the response body; a different endpoint version returns {'message': ...} with status 200.","commonSituations":"Together shipping a response-format change that LiteLLM's current version doesn't handle; middlewares (mock servers, gateway rewrites) returning stub JSON; edge cases where Together returns an empty result set as null.","solutions":["Upgrade (or pin) litellm to a release matching the current Together rerank response schema.","Inspect the response echoed in the message to see what Together actually returned (often an inline error object).","If a mock/proxy intercepts the call, make it return {'results': [...], 'usage': {...}} shaped payloads.","Report the exact response body to litellm maintainers if the provider changed its contract."],"exampleFix":"# before (mock/interceptor returns wrong shape)\n# 200 OK body: {\"message\": \"ok\"}\nresp = litellm.rerank(model=\"together_ai/rerank-english-v2.0\", query=q, documents=docs)\n# ValueError: No results found in the response={'message': 'ok'}\n\n# after — return the documented shape\n# 200 OK body: {\"results\": [{\"index\": 0, \"relevance_score\": 0.98}], \"usage\": {...}}\nresp = litellm.rerank(model=\"together_ai/rerank-english-v2.0\", query=q, documents=docs)","handlingStrategy":"try-catch","validationCode":"def looks_like_together_rerank_response(body: dict) -> bool:\n    \"\"\"Cheap contract check when you control/mock the response source.\"\"\"\n    return isinstance(body, dict) and isinstance(body.get(\"results\"), list)","typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.rerank(model=\"together_ai/rerank-english-v2.0\", query=q, documents=docs)\nexcept ValueError as e:\n    if \"No results found in the response\" in str(e):\n        # provider contract break: log body for maintainers, fall back to no rerank\n        logger.warning(\"together rerank returned no results: %s\", e)\n        resp = None\n    else:\n        raise","preventionTips":["Pin litellm versions and test against a recorded (VCR) Together response so contract drift is caught in CI.","Make mock servers return documented shapes including 'results'.","Treat parse ValueErrors as provider-contract incidents — report with the echoed response body."],"tags":["together-ai","rerank","response-parsing","api-contract","litellm"],"backgroundTag":"unexpected-api-response","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}