Skip to content

fix(platform): stop hiding an email attachment that carries a Content-ID - #3009

Merged
Israeltheminer merged 1 commit into
mainfrom
fix/inline-attachment-filter
Aug 19, 2026
Merged

Israeltheminer merged 1 commit into
mainfrom
fix/inline-attachment-filter

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

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 contentId and a url:

.filter((att) => !(att.contentId && att.url))

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 materializeEmailAttachments gives every stored attachment a url — 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 fileMetadata row existed with a storageId, 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:…" or href="cid:…" reference in the HTML.

  • an unreferenced part stays visible whatever headers it carries
  • a referenced inline image with no url yet 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
  • a reference is percent-decoded before comparison, because it can be escaped while the header value is not

Tests

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 && url filter, 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 fileMetadata row 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.

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.
@Israeltheminer

Copy link
Copy Markdown
Contributor Author

Confirmed against the reported message on a live deployment. Its metadata.attachments[0] carries all three of contentId, url and storageId, so the old contentId && url filter hid it. The attachment was stored and reachable the whole time.

Two details worth recording.

The sender's client set a real Content-ID on an ordinary PDF part. mailAttachmentsFromParsed reads it from what the sender sent and does not fabricate one, so the connector is faithful and needs no change. Attachments sent from the platform's own compose path carry no Content-ID, which is why self-sent tests displayed correctly and inbound mail did not.

That message's body is empty — content, html and text are each a single newline. There is no HTML and therefore no cid: reference, so under this change the attachment shows. The old filter hid it on the header alone, with nothing in the body to justify treating it as inline.

@Israeltheminer
Israeltheminer merged commit 5844418 into main Aug 19, 2026
47 of 49 checks passed
@Israeltheminer
Israeltheminer deleted the fix/inline-attachment-filter branch August 19, 2026 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant