From 093eec3105c5029a06d0d135120fa062ba32acc1 Mon Sep 17 00:00:00 2001 From: buua436 Date: Wed, 10 Jun 2026 13:05:24 +0800 Subject: [PATCH] fix: handle qwen rerank error response (#15881) ### What problem does this PR solve? Fix QWen rerank error handling so DashScope error responses without a text attribute do not raise a secondary KeyError and hide the real provider error. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/llm/rerank_model.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/rag/llm/rerank_model.py b/rag/llm/rerank_model.py index c149b23074..9705d5c66a 100644 --- a/rag/llm/rerank_model.py +++ b/rag/llm/rerank_model.py @@ -432,7 +432,16 @@ class QWenRerank(Base): log_exception(_e, resp) return rank, total_token_count_from_response(resp) else: - raise ValueError(f"Error calling QWenRerank model {self.model_name}: {resp.status_code} - {resp.text}") + try: + error_body = resp["text"] if isinstance(resp, dict) and "text" in resp else None + except Exception: + error_body = None + if not error_body: + try: + error_body = json.dumps(dict(resp), ensure_ascii=False) + except Exception: + error_body = str(resp) + raise ValueError(f"Error calling QWenRerank model {self.model_name}: {resp.status_code} - {error_body}") class HuggingfaceRerank(Base):