Repository navigation
fix(platform): stop hiding an email attachment that carries a Content-ID - #3009
Conversation
An emailed PDF was stored, given a download URL, written into its message metadata, and then filtered out of the Inbox before render. The file looked like it had never arrived, so an operator reasonably concluded the sender never attached one. The list hid anything carrying both a contentId and a url, treating a Content-ID as proof the part was an inline image already drawn in the body. It is not. Many mail clients stamp Content-ID on ordinary file parts, and `materializeEmailAttachments` gives every stored attachment a url, so those two conditions were met by a perfectly ordinary attachment. That is why a self-sent test worked while real mail did not: the test client omits Content-ID. An attachment is now hidden only when the body actually draws it — its cid appears in a `src="cid:…"` or `href="cid:…"` reference in the HTML. An unreferenced part stays visible whatever headers it carries, and a referenced inline image with no url yet still stays visible so it can be downloaded by hand when the auto-download fails. `normalizeCid` moves to module scope so the cid map and the reference test compare values the same way, and a reference is percent-decoded before comparison because it can be escaped while the header value is not.
|
Confirmed against the reported message on a live deployment. Its Two details worth recording. The sender's client set a real Content-ID on an ordinary PDF part. That message's body is empty — |
An email attachment that carries a Content-ID now appears in the Inbox. Before this, it was stored, given a download URL, written into its message metadata, and then filtered out before render — so the file looked like it had never arrived.
Why
The list hid anything carrying both a
contentIdand aurl:That treats a Content-ID as proof the part is an inline image already drawn in the body. It is not. Many mail clients stamp Content-ID on ordinary file parts, and
materializeEmailAttachmentsgives every stored attachment aurl— so both conditions were met by a perfectly ordinary attachment.This is why a self-sent test worked while real mail did not: the test client omits Content-ID.
Reported from a live deployment. The
fileMetadatarow existed with astorageId, which is what narrowed it to display rather than to ingest.What changed
An attachment is hidden only when the body actually draws it — its cid appears in a
src="cid:…"orhref="cid:…"reference in the HTML.urlyet stays visible, so it can be downloaded by hand when the auto-download failsnormalizeCidmoves to module scope, so the cid map and the reference test compare values the same wayTests
Six cases: an unreferenced attachment with a cid shows, a drawn inline image hides, both together behave correctly, no cid at all shows, a referenced image with no url shows, and an escaped reference still matches.
Mutations, all red: restoring the old
contentId && urlfilter, hiding nothing at all, dropping the percent-decode, and no longer stripping angle brackets from a Content-ID.Scope
Display only. Ingest, storage and the
fileMetadatarow are unchanged.Does not make email attachments searchable. They are still skipped for RAG by #2995, which was deliberate. Making them searchable needs the attachment bound to its conversation first (#2985), so visibility can be derived from the conversation's current assignment rather than stamped at ingest and left to drift.