Preserve CLIP client errors through qdrant

This commit is contained in:
2026-08-29 09:19:38 +02:00
parent d5faa49c47
commit 32ddf70e2f
4 changed files with 122 additions and 9 deletions
+16 -1
View File
@@ -47,6 +47,21 @@ class EmbedRequest(BaseModel):
pretrained: Optional[str] = None
_TRANSIENT_IMAGE_ERRORS = {
"dns_failure",
"connect_timeout",
"read_timeout",
"connection_error",
"remote_http_5xx",
"fetch_failure",
}
def _image_load_status(error: ImageLoadError) -> int:
"""Keep input failures as 4xx and surface transient/unknown failures as 5xx."""
return 502 if error.category in _TRANSIENT_IMAGE_ERRORS or error.category == "unknown" else 400
def _log_image_load_failure(error: ImageLoadError, url: str, elapsed_ms: float) -> None:
fields = {
"event": "clip_image_fetch_failed",
@@ -167,7 +182,7 @@ def embed(req: EmbedRequest):
return _embed_image_bytes(data, backend=req.backend, model_name=req.model, pretrained=req.pretrained)
except ImageLoadError as e:
_log_image_load_failure(e, req.url, (time.perf_counter() - started_at) * 1000)
raise HTTPException(400, str(e))
raise HTTPException(_image_load_status(e), str(e))
@app.post("/embed/file")