From 694aa7e4fb55c0bee29fc9298b26f8be6a5629af Mon Sep 17 00:00:00 2001 From: goodnight Date: Sun, 6 Sep 2026 17:58:05 +0100 Subject: [PATCH] fix: show server error text, fix upload retry warning --- qdrant_client/http/exceptions.py | 11 +++++++++++ qdrant_client/uploader/grpc_uploader.py | 9 ++++----- qdrant_client/uploader/rest_uploader.py | 9 ++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/qdrant_client/http/exceptions.py b/qdrant_client/http/exceptions.py index 45437e1c0..f6980490c 100644 --- a/qdrant_client/http/exceptions.py +++ b/qdrant_client/http/exceptions.py @@ -33,10 +33,21 @@ def __str__(self) -> str: else: reason_phrase_str = f"({self.reason_phrase})" status_str = f"{status_code_str} {reason_phrase_str}".strip() + error = self._server_error() + if error is not None: + return f"Unexpected Response: {status_str}\nError: {error}" short_content = self.content if len(self.content) <= MAX_CONTENT else self.content[: MAX_CONTENT - 3] + b" ..." raw_content_str = f"Raw response content:\n{short_content!r}" return f"Unexpected Response: {status_str}\n{raw_content_str}" + def _server_error(self) -> Optional[str]: + """Return `status.error` from a Qdrant JSON error body, or None if absent or unparsable.""" + try: + error = json.loads(self.content).get("status", {}).get("error") + except (ValueError, TypeError, AttributeError): + return None + return error if isinstance(error, str) and error else None + def structured(self) -> Dict[str, Any]: return json.loads(self.content) diff --git a/qdrant_client/uploader/grpc_uploader.py b/qdrant_client/uploader/grpc_uploader.py index 55451090f..7400999df 100644 --- a/qdrant_client/uploader/grpc_uploader.py +++ b/qdrant_client/uploader/grpc_uploader.py @@ -67,15 +67,14 @@ def upload_batch_grpc( sleep(ex.retry_after_s) except Exception as e: + if attempt == max_retries - 1: + raise + show_warning( - message=f"Batch upload failed {attempt + 1} times. Retrying...", + message=f"Batch upload failed {attempt + 1} times ({type(e).__name__}: {e}). Retrying...", category=UserWarning, stacklevel=8, ) - - if attempt == max_retries - 1: - raise e - attempt += 1 return True diff --git a/qdrant_client/uploader/rest_uploader.py b/qdrant_client/uploader/rest_uploader.py index 75262b6ec..cde0c2d81 100644 --- a/qdrant_client/uploader/rest_uploader.py +++ b/qdrant_client/uploader/rest_uploader.py @@ -62,15 +62,14 @@ def upload_batch( sleep(ex.retry_after_s) except Exception as e: + if attempt == max_retries - 1: + raise + show_warning( - message=f"Batch upload failed {attempt + 1} times. Retrying...", + message=f"Batch upload failed {attempt + 1} times ({type(e).__name__}: {e}). Retrying...", category=UserWarning, stacklevel=7, ) - - if attempt == max_retries - 1: - raise e - attempt += 1 return True