Files
kirillk 51a361ee68 fix(cli): make the attachment precheck and image fallback agree
The HTTP-boundary precheck judged a raster data URL by its decoded content,
while Image.fallback -- the path taken when Photon fails to load -- still
required a canonical base64 round-trip and validated against the declared
mime. The two disagreed, so a line-wrapped payload or an image labelled with
the wrong raster mime could pass the boundary and then die with DecodeError
inside resolvePart's orDie. On prompt_async that surfaces only after the route
already returned 204, which is exactly the prompt loss the precheck exists to
prevent.

Single-source the decision as Image.decodable, which sniffs the real format
the way Photon's new_from_byteslice does, and use it from both the precheck
and fallback so they cannot drift apart again. Dropping fallback's canonical
check loses no protection: the magic-byte parse in dimensions is the stronger
guard, and it still rejects BMP, which Photon traps on.

Reported by kilo-code-bot.
2026-10-07 13:42:30 -04:00
..