Classify invalid image content types

This commit is contained in:
2026-08-29 08:01:39 +02:00
parent 4ed3b619be
commit 5248deb54e
+6 -1
View File
@@ -102,7 +102,12 @@ def fetch_url_bytes(url: str, timeout: float = 10.0, max_bytes: int = DEFAULT_MA
content_type = (r.headers.get("content-type") or "").lower()
if content_type and not content_type.startswith("image/"):
raise ImageLoadError(f"URL does not point to an image content type: {content_type}")
raise _error(
f"URL does not point to an image content type: {content_type}",
category="invalid_content_type",
stage="fetch",
metadata={"content_type": content_type, "remote_status": r.status_code},
)
buf = io.BytesIO()
total = 0