Repository navigation
[Bugfix] Classify Inkling media errors as client errors (HTTP 400) instead of server faults (500) - #40931
[Bugfix] Classify Inkling media errors as client errors (HTTP 400) instead of server faults (500)#40931apex-mochen wants to merge 1 commit into
Conversation
…stead of server faults (500) Fixes sgl-project#40897. (AI-assisted) Co-authored-by: AI assistant
|
Closing this as a duplicate of #40899, which I should have found before writing it. What I checked before opening it: nothing beyond the issue. I did not search for open PRs touching these files, so I did not see that #40899 was already up — opened 2026-09-23T10:45Z, four and a half hours before this one, fixing the same issue (#40897) with the same three files ( That is the process failure worth recording, not the code: the diagnosis here was fine, but a technically correct patch that duplicates an earlier one has no merge path, and mine is also the worse patch of the two — So: no changes requested here, nothing to rebase. #40899 is the one to review. If anything in this branch turns out to be covered there but untested — the Sorry for the duplicate. Closing. |
Motivation
Fixes #40897. When an Inkling model receives invalid client-supplied media — an empty
image_url, an unreachable media host, or undecodable image bytes — the server responds HTTP 500 instead of 400. Clients cannot distinguish their own bad request from a genuine server fault, and client input errors pollute server-error monitoring.Every other VLM processor routes media through
BaseMultimodalProcessor._load_single_item, where #31417 added theCLIENT_MEDIA_EXCEPTIONSclassification (ValueError/UnidentifiedImageError/requestsexceptions →ValueError). Inkling bypasses that path: it resolves request media inprocessors/inkling.py::_resolve_media_itemand decodes image bytes ininkling/image_processing.py::_encode_image_bytes, so the classification never applies. Rawrequests.exceptions.ConnectionError,UnidentifiedImageError, and the laterFileNotFoundErrorfrom an empty URL escape unclassified and land on the server-fault path.Modifications
_resolve_media_item:ValueErrorinstead of returning""(which previously died asFileNotFoundErrorfurther down the line → 500).download_remote_mediacalls are wrapped: anyCLIENT_MEDIA_EXCEPTIONS(DNS/connection failure, timeout, redirect loop, oversized payload, bad URL) is re-raised asValueErrorwith the original exception chained, mirroringBaseMultimodalProcessor._load_single_itemand the llava processor._encode_image_bytes: PILUnidentifiedImageErrorfromImage.openon undecodable client bytes is wrapped intoValueError("Could not decode image bytes: ..."), cause chained.test/registered/unit/multimodal/test_inkling_media_errors.pycovering: empty-URL variants;ConnectionError/Timeout/TooManyRedirectswrapping with cause preserved; invaliddata:base64; validdata:round-trip; local path / raw bytes passthrough; undecodable image bytes →ValueErrorwith PIL cause; and a real small PNG still encodes (no regression on the happy path).Accuracy Tests
N/A — this only changes error-path exception classification; no model forward or output computation is touched. Happy paths were verified unchanged locally: valid
data:URLs round-trip byte-exact, local paths and raw bytes pass through, and a real 14x14 PNG still produces the expected patch tensor.Speed Tests and Profiling
N/A — no hot-path code: one
.strip()on URLs and exception wrappers around already-remote IO / decode steps.Checklist
CLIENT_MEDIA_EXCEPTIONS→ValueError).Local CPU verification (heavy deps stubbed, real modules loaded):
""silently; rawConnectionErrorand rawUnidentifiedImageErrorpropagated.CI States
Latest PR Test (Base): ❌ Run #35880343869
Latest PR Test (Extra): ❌ Run #35880343693
Latest PR Test (AMD ROCm 10): ❌ Run #35880343734