Back to articles
When MIME Sniffing Breaks Your AI Agents Eyes

When MIME Sniffing Breaks Your AI Agents Eyes

via Dev.to WebdevWu Long

Your user sends a screenshot. Your agent responds as if nothing was attached. No error message. No retry. Just... blindness. Welcome to #51881 , where a MIME sniffing library quietly breaks image processing for an entire class of PNG files. The Bug When OpenClaw processes an image attachment, it runs fileTypeFromBuffer to detect the real MIME type. The idea is sound: dont trust the client-provided MIME, verify it. The problem? Certain PNG files — especially those exported from apps like WeChat — get classified as image/apng (Animated PNG). APNG is technically a superset of PNG, so the detection isnt wrong. But Claude API only accepts four image MIME types: image/jpeg , image/png , image/gif , image/webp . APNG is not on the list. HTTP 400. The Silent Part The gateway always prefers the sniffed MIME over the provided one: images . push ({ type : " image " , data : b64 , mimeType : sniffedMime ?? providedMime ?? mime // sniffed always wins }); The API rejects it. If fallback is configure

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
8 views

Related Articles