Skip to content

fix: prevent silent attachment loss on email forwarding#166

Open
neilhtennek wants to merge 1 commit intoinboundemail:mainfrom
neilhtennek:fix/silent-attachment-loss
Open

fix: prevent silent attachment loss on email forwarding#166
neilhtennek wants to merge 1 commit intoinboundemail:mainfrom
neilhtennek:fix/silent-attachment-loss

Conversation

@neilhtennek
Copy link
Copy Markdown

@neilhtennek neilhtennek commented Apr 9, 2026

Problem

When getAttachmentContent() fails to retrieve an attachment (missing raw email data, malformed MIME, parser error), the forwarder logs a warning and calls continue — silently skipping the attachment. The email still forwards and gets marked as delivered. The success log even reports the original attachment count, not the actual number included.

This means a user can receive a forwarded email that is missing attachments with no indication that anything went wrong. Silent data loss.

Fix

Replace the continue with a throw so the forwarding operation fails visibly when an attachment cannot be retrieved. The existing error handling in the caller (email-router.ts) already catches this, marks the email as failed, and logs the error — so the failure surfaces properly instead of being swallowed.

Before

if (!attachmentContent) {
  console.warn(`Could not retrieve content for attachment`)
  continue  // email sends without the attachment, marked as delivered
}

After

if (!attachmentContent) {
  throw new Error(`Failed to retrieve content for attachment. Aborting forward to prevent silent data loss.`)
}

One line change. No new dependencies.


@neilhtennek | @PreviewOps

When getAttachmentContent() returns null, the forwarder was silently
skipping the attachment and continuing with the send. The email would
be marked as successfully delivered with the original attachment count
logged, but the actual forwarded email could be missing attachments.

This changes the behavior to throw an error when an attachment can't
be retrieved, so the forwarding fails visibly and can be retried or
flagged instead of silently losing data.
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 9, 2026

@neilhtennek is attempting to deploy a commit to the inbound Team on Vercel.

A member of the Team first needs to authorize it.

@neilhtennek
Copy link
Copy Markdown
Author

@R44VC0RP

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