BerriAI/litellm · error · DashScopeError

No results in DashScope rerank response: {response_json}

Error message

No results in DashScope rerank response: {response_json}

What it means

Raised when a DashScope rerank response parses as JSON, contains no error envelope, but is missing the 'results' key entirely (results is None). This is an unexpected/contract-violating response shape, and the full response body is embedded in the exception message for diagnosis.

Source

Thrown at litellm/llms/dashscope/rerank/transformation.py:194

            )

        logging_obj.post_call(
            input=request_data.get("query"),
            api_key=api_key,
            additional_args={"complete_input_dict": request_data},
            original_response=response_json,
        )

        # DashScope error envelope: {"code": "...", "message": "...", "request_id": "..."}
        if "code" in response_json and "results" not in response_json:
            raise DashScopeError(
                status_code=raw_response.status_code,
                message=response_json.get("message", str(response_json)),
            )

        results: Final = response_json.get("results")
        if results is None:
            raise DashScopeError(
                status_code=raw_response.status_code,
                message=f"No results in DashScope rerank response: {response_json}",
            )

        # qwen3-rerank returns:
        #   {"index": int, "relevance_score": float}
        # plus, when return_documents=true was sent:
        #   "document": {"text": "..."}
        # which already matches LiteLLM's RerankResponseDocument shape.
        transformed_results: Final[list[dict]] = []
        for r in results:
            item: dict[str, Any] = {
                "index": r["index"],
                "relevance_score": r["relevance_score"],
            }
            doc = r.get("document")
            if isinstance(doc, dict):
                item["document"] = doc

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Log the full response body included in the message to see what DashScope actually returned
  2. Reproduce with a minimal curl request to the rerank endpoint to check the raw schema
  3. Retry once — degraded responses are often transient
  4. If the schema genuinely changed, upgrade litellm to the latest patch where the transformer may be fixed, or report the response shape to the litellm repo
Defensive patterns

Strategy: fallback

Try / catch

try:
    resp = litellm.rerank(model=m, query=q, documents=docs)
except Exception as e:
    if "No results in DashScope rerank response" in str(e):
        logger.warning("rerank degraded, falling back to original order: %s", e)
        return docs  # fallback: unranked documents
    raise

Prevention

When it happens

Trigger: DashScope returns 200 with an atypical body: a partial/degraded response during incidents, a new API version changing the response schema, or an endpoint that ignores the rerank path and returns a generic payload.

Common situations: DashScope service degradation; hitting a base URL that serves a different API surface; DashScope shipping a schema change that LiteLLM has not yet adapted to (version skew between litellm and the API).

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/142c3546e5be77bb. Report an issue: GitHub.