#12700·novu

Bug Report: Topic triggers: attachments are empty for all but the first subscriber in v3.19.0 (follow-up to NV-8533 / #12248)

Author: tszyszkoCreated Sep 23, 2026Updated Sep 24, 2026
Labelstriage

Description

In self-hosted Novu v3.19.0, emails sent via a topic trigger arrive with attachment parts that have correct headers but an empty body. Inline images referenced with cid: render as broken images. The trigger payload contains a valid, non-empty base64 file in payload.attachments[].file.

Raw MIME from a delivered message (custom SMTP provider):

  Content-Type: image/png; name=logo.png
  Content-ID: <logo@example>
  Content-Transfer-Encoding: base64
  Content-Disposition: inline; filename=logo.png

  (empty)

Reproduction steps

  1. Self-hosted Novu v3.19.0 with object storage configured for attachments.
  2. Workflow with one email step whose body contains <img src="cid:logo@example">.
  3. Create a topic with 2+ subscribers.
  4. Trigger the workflow to the topic with: payload.attachments = [{ file: <base64 png>, name: "logo.png", mime: "image/png", cid: "logo@example" }]
  5. Inspect the raw emails: the first subscriber to be processed gets the image; the rest get an empty image/png part. The same trigger sent to a topic with a single subscriber delivers the image correctly.

Expected behavior

Every subscriber of a topic (or multi-recipient) trigger receives the attachment content.

Actual Behavior with Screenshots

  Content-Type: image/png; name=logo.png
  Content-ID: <logo@example>
  Content-Transfer-Encoding: base64
  Content-Disposition: inline; filename=logo.png

  (empty)

Novu version

v3.19.0

npm version

No response

node version

No response

Provide any additional context for the Bug.

AI proposed fix: NV-8533 (#12247, superseded by #12248 / 7bf2e9c4833701bf0c853b2955b1201edb9448cc) fixed zero-byte attachments caused by payload-dedup (#11976): the finally block in tryQueueNextJobs deleted stored attachments after the trigger job, before the channel step ran. #12248 moved cleanup to deleteChainAttachments(), which runs when a job chain finishes.

That fixes a single-subscriber chain, but the deletion is still scoped to one chain, while the stored file is shared by every chain created from the same trigger.

Root cause

For a topic trigger, ParseEventRequest uploads each attachment once to a single storagePath ({orgId}/{envId}/{randomId}/{name}). Fan-out then creates one notification and one job chain per subscriber, all pointing at that same storagePath.

When the first subscriber's chain completes, deleteChainAttachments() deletes the object. Every subscriber processed after that hits NoSuchKey in StorageHelperService.getAttachments(), which sets attachment.file = null without raising an error, and the channel step sends an attachment part with an empty body. This is the same symptom as NV-8533, via a different path.

The verification in #12247 and the tests added in #12248 cover a single subscriber (one and two email steps); multi-subscriber / topic triggers are not exercised.

Delete trigger attachments only when all jobs for the trigger's transactionId are in a terminal state (reference count, or a check for remaining non-terminal jobs with the same transactionId), or give each subscriber its own copy at fan-out. Separately, consider logging a warning when getAttachments() finds the stored file missing instead of setting file = null without notice, since both NV-8533 and this issue were invisible until recipients reported them.

Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!