← Back to Pull requests

Write the Alert Dispatched event when an alert value is null #573

Closed
unknown closed this pull request without merging on Nov 17, 2026 14:12 UTC
View on GitHub
unknown unknown commented on Nov 11, 2026 18:36 UTC
Author

Closes #572.

When an alert fires, its actions go out first. Then AlertWorker.ActionTask builds the "Alert Dispatched" event by calling toString() on every value in the alert's context. A null value throws, and the task runs on an executor whose Future nobody reads, so the event is never written and nothing is logged.

It's not only the server name. A source transformer that throws, or a call to alerts.sendAlert(...), leaves connectorType null, and those alerts never wrote the event either, server name or not. Measured below.

The blank server name case is courtesy of #259, which put serverName in the context. Tony spotted the null in review, wrote a nice paragraph about it, and it still collected three approvals, with #47 lined up to fill it in. #47 is still lined up. In fairness, the toString() loop that actually throws has been sitting there since Mirth.

Change

  • A null context value becomes an empty attribute, Objects.toString(value, ""). AuthorizationController does the same for audit events, and empty is also what the #259 thread wanted for the template variable.

  • The event step gets the same try/catch and logger.error the protocol and email steps in that method already have, so if it breaks again it says so.

  • Alert templates are untouched. With no server name set, ${serverName} still renders as the literal token, as discussed in #259, and so does ${connectorType} on transformer and alerts.sendAlert alerts. Checked on an engine built from this branch.

  • Heads-up for upgrades: alerts on transformer errors or alerts.sendAlert, and any alert on a server with no name, will start writing an "Alert Dispatched" event per action. They never did before. Each one carries the full error text in error and errorMessage, same as the events that were already being written.
  • AlertWorkerTest covers a null server name and connector type, a set server name, and a failing dispatch getting logged. The first and the last fail on main.

    How to verify

    Fresh engine on Derby, no server name set (Settings, Server, Server Name empty).

    1. Create a channel "Receiver": Channel Reader source, any destination.
    2. Create a channel "Throws": Channel Reader source, JavaScript Writer destination with throw new Error('boom');.
    3. Create a channel "Transformer Throws": Channel Reader source with a JavaScript transformer step throw new Error('transformer boom');, any destination.
    4. Create an alert on any error for "Throws" and "Transformer Throws", with a Channel action to "Receiver". Enable it and deploy all three channels.
    5. Send a message to "Throws".
    6. Set a Server Name and save. Send a message to "Transformer Throws".
    7. Look in Events for "Alert Dispatched".

    Before: "Receiver" gets both alert messages, but neither "Alert Dispatched" event is written, and mirth.log says nothing about it. After: both events are there, with serverName blank on the first and connectorType blank on the second.

    Tested

    ./gradlew clean build -x signSetupJars: 913 tests, 0 failures, 0 skipped.

    Live on Derby, one engine built from main (cd802efd1) and one from this branch, one message per row:

    | Scenario | Alert action delivered (main / this PR) | Alert Dispatched event (main / this PR) |
    |---|---|---|
    | No server name, JavaScript Writer throws | yes / yes | missing / written, serverName blank |
    | Server name set, JavaScript Writer throws (control) | yes / yes | written / written |
    | Server name set, source transformer throws | yes / yes | missing / written, connectorType blank |
    | Server name set, alerts.sendAlert(...) | yes / yes | missing / written, connectorType blank |

    On main, mirth.log has nothing about the three missing events. On this branch the new error line never shows up, since nothing failed.

    Release Note

    The "Alert Dispatched" event is no longer skipped when an alert value is missing

    When an alert fired, its actions went out, but the "Alert Dispatched" event wasn't written if one of the alert's values was missing, and nothing was logged. That happened for any error alert while Settings, Server, Server Name was blank, and for alerts on source transformer errors or alerts.sendAlert(...), which carry no connector type. The event is now written with those values as empty attributes, and a failure to write it is logged. (#572, #573)

    After upgrading, installs with such alerts will see "Alert Dispatched" events they didn't get before. Alert templates are unchanged: with no server name set, ${serverName} still renders as the literal ${serverName}.

    Co-authored with Claude Code.

    Diff: 576 lines (+432 / -144) across 7 files Reviewer: pacmano1 Review duration: 8376m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 576 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.380
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #573"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 49.8% (MEDIUM) · Higher = larger blast radius
    49.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.7% · Safe to merge
    19.7%