{"record":{"id":"142c3546e5be77bb","repo":"BerriAI/litellm","slug":"no-results-in-dashscope-rerank-response-response","errorCode":null,"errorMessage":"No results in DashScope rerank response: {response_json}","messagePattern":"No results in DashScope rerank response: (.+?)","errorType":"exception","errorClass":"DashScopeError","httpStatus":null,"severity":"error","filePath":"litellm/llms/dashscope/rerank/transformation.py","lineNumber":194,"sourceCode":"            )\n\n        logging_obj.post_call(\n            input=request_data.get(\"query\"),\n            api_key=api_key,\n            additional_args={\"complete_input_dict\": request_data},\n            original_response=response_json,\n        )\n\n        # DashScope error envelope: {\"code\": \"...\", \"message\": \"...\", \"request_id\": \"...\"}\n        if \"code\" in response_json and \"results\" not in response_json:\n            raise DashScopeError(\n                status_code=raw_response.status_code,\n                message=response_json.get(\"message\", str(response_json)),\n            )\n\n        results: Final = response_json.get(\"results\")\n        if results is None:\n            raise DashScopeError(\n                status_code=raw_response.status_code,\n                message=f\"No results in DashScope rerank response: {response_json}\",\n            )\n\n        # qwen3-rerank returns:\n        #   {\"index\": int, \"relevance_score\": float}\n        # plus, when return_documents=true was sent:\n        #   \"document\": {\"text\": \"...\"}\n        # which already matches LiteLLM's RerankResponseDocument shape.\n        transformed_results: Final[list[dict]] = []\n        for r in results:\n            item: dict[str, Any] = {\n                \"index\": r[\"index\"],\n                \"relevance_score\": r[\"relevance_score\"],\n            }\n            doc = r.get(\"document\")\n            if isinstance(doc, dict):\n                item[\"document\"] = doc","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/llms/dashscope/rerank/transformation.py#L176-L212","documentation":"The rerank response parsed as JSON and carried no error 'code', but the 'results' key was absent/None, so the transformer refuses to build a RerankResponse and raises DashScopeError embedding the entire response body in the message. It means DashScope returned HTTP 200 with an unexpected or empty schema rather than an explicit error.","triggerScenarios":"A non-rerank model answering /reranks with a different body shape; DashScope changing/wrapping the results field (e.g. nesting under 'output'); zero documents surviving upstream filtering; api_base routing to a compatibility endpoint whose JSON differs from the native rerank schema.","commonSituations":"Model naming mismatch (chat/embedding model used on the rerank route); a gateway returning valid-but-different JSON; DashScope schema drift not yet handled by the installed LiteLLM version.","solutions":["Log the full response JSON (it is embedded in the message) and diff it against DashScope's documented rerank response shape","Confirm the model genuinely supports the rerank API (gte-rerank, qwen3-rerank families)","Ensure DASHSCOPE_API_BASE is not pointing at a compatibility endpoint with a different response schema","Upgrade LiteLLM — response transformers get updated as schemas change; if the body is valid per DashScope docs, file an issue with the logged payload"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"RERANK_ALLOWED_MODELS = {'gte-rerank', 'gte-rerank-v2', 'qwen3-rerank-0.6b'}\n\ndef model_allows_rerank(model: str) -> bool:\n    return model.split('/', 1)[-1].split(':')[0] in RERANK_ALLOWED_MODELS","typeGuard":null,"tryCatchPattern":"try:\n    results = litellm.rerank(model='dashscope/gte-rerank', query=q, documents=docs)\nexcept Exception as e:\n    if 'No results in DashScope rerank response' in str(e):\n        log_schema_drift(e)\n        results = fallback_rerank(q, docs)  # e.g. cohere/jina via same litellm.rerank\n    else:\n        raise","preventionTips":["Pin rerank models to a known-good allowlist so schema drift fails loudly in CI","Run a canary rerank call against the real endpoint in integration tests to catch response-shape changes early"],"tags":["dashscope","rerank","response-schema","empty-results"],"backgroundTag":"unexpected-response-schema","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}