Skip to content

templates: Notification.java.template stamps notify outcome only for a Mail.send failure - a relation load or attachment render failure leaves the record unstamped (#7233 sibling) #7290

Description

@delchev

Describe the bug

Sibling of #7233 / PR #7278, found by grepping the other notify templates for the same shape. Notification.java.template (template-application-events-java) stamps outcome: only when Mail.send throws:

// events/Notification.java.template
#foreach($load in $relationLoads)
        ${load.targetEntity}Entity ${load.local} = ... new ${load.targetEntity}Repository().findById(entity.${load.fkProperty});   // before the try
#end
        ...
        try {
            data = org.eclipse.dirigible.sdk.print.Print.render("${attachEntity}", language, ...);   // try/finally, no catch
        } finally { ... }
        ...
        try {
            Mail.send(from, new String[] {to}, ..., subject, parts);
            stampNotifyOutcome(entity.${notifyOutcomeKeyProperty}, null);
        } catch (Exception ex) {
            stampNotifyOutcome(entity.${notifyOutcomeKeyProperty}, ex);
            throw new RuntimeException("Failed to send notification ${name}", ex);
        }

A relation load that throws (a connection blip, a repository refusing), a Print.render failure (a broken .print template, a missing CMS image past the size limit is soft but a parse error is not) or the report-attach path failing propagates out of onMessage with no stamp: the broker redelivers, the onError log line is the only trace, and the record's outcome: field stays empty - the "silent by construction" state #7023 introduced outcome: to remove, and -notifyFailed never fires, so event: { onNotifyFailed: ... } cannot react either. PR #7278 fixed exactly this for the schedule fan-out (Job.java.template:304-309 now stamps a load/render failure); the single-record listener did not get the same treatment. Transition.java.template and Send.java.template already open their try before the loads.

Expected

The relation loads and the attachment render sit inside the same try as the send in Notification.java.template, so every failure of the delivery attempt stamps failed: <reason> and raises -notifyFailed, exactly as the notify branch of Job.java.template does since #7278. A test that breaks the render (an unparsable .print) and asserts the stamp.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions