Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions qdrant_client/http/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 4 additions & 5 deletions qdrant_client/uploader/grpc_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 4 additions & 5 deletions qdrant_client/uploader/rest_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down