{"record":{"id":"551c535bcb48f2a3","repo":"BerriAI/litellm","slug":"response-json-get-message-str-response-json","errorCode":null,"errorMessage":"response_json.get(\"message\", str(response_json)) (upstream DashScope error message)","messagePattern":"response_json\\.get\\(\"message\", str\\(response_json\\)\\) \\(upstream DashScope error message\\)","errorType":"http","errorClass":"DashScopeError","httpStatus":null,"severity":"error","filePath":"litellm/llms/dashscope/rerank/transformation.py","lineNumber":187,"sourceCode":"        litellm_params = litellm_params or {}\n        try:\n            response_json: Final = raw_response.json()\n        except Exception:\n            raise DashScopeError(\n                status_code=raw_response.status_code,\n                message=raw_response.text,\n            )\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:","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/dashscope/rerank/transformation.py#L169-L205","documentation":"Raised when the DashScope rerank response carries the DashScope error envelope ({\"code\": ..., \"message\": ..., \"request_id\": ...}) without a 'results' field. The exception message is the upstream 'message' value (or the whole body if absent) and the status code comes from the HTTP response.","triggerScenarios":"DashScope rerank API call rejected server-side: invalid model (code InvalidParameter.ModelNotFound), expired API key (InvalidApiKey), throttling (Throttling), or input exceeding limits — any case where the response contains 'code' but no 'results'.","commonSituations":"Model name typo for qwen3-rerank/gte-rerank variants; API key rotated but old one cached in env; QPS/quota throttling under bursty RAG traffic; documents payload too large.","solutions":["Match the upstream 'code' field in the response body to DashScope's error-code docs to pinpoint the cause","For throttling errors, add retry with exponential backoff and respect QPS limits","For auth errors, refresh DASHSCOPE_API_KEY","For parameter errors, validate model name and documents/query sizes before calling","Include the request_id from the body when opening a support case with Alibaba Cloud"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.rerank(model=m, query=q, documents=docs)\nexcept Exception as e:\n    msg = str(e)\n    if \"Throttling\" in msg or \"RateLimit\" in msg:\n        resp = backoff_retry(lambda: litellm.rerank(model=m, query=q, documents=docs))\n    elif \"ApiKey\" in msg or \"Unauthorized\" in msg:\n        raise ConfigError(\"DASHSCOPE_API_KEY invalid\") from e\n    else:\n        raise","preventionTips":["Map DashScope 'code' values (Throttling/InvalidApiKey/InvalidParameter) to distinct handling branches","Respect QPS limits with a client-side rate limiter for rerank traffic","Keep the response request_id in logs to correlate with Alibaba Cloud support"],"tags":["dashscope","rerank","upstream-error","api"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}