fix: Handle null monitor in workspace notification rules #37

Closed
opened 2026-04-05 16:18:44 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @Eliaxie on 3/11/2026

Fixes #2348

Problem

Alerts without monitors were causing workspace notifications (Slack/Teams) to crash with:

TypeError: Cannot read properties of null (reading 'id')
    at Service.getValuesBasedOnNotificationFor (WorkspaceNotificationRuleService.ts:2068:26)

Root Cause

Regression introduced in commit 76ab3a8cd6 which removed optional chaining:

-          alert.monitor?.id!.toString() || "",
+          alert.monitor!.id!.toString() || "",

Solution

Restore proper null handling:

alert.monitor?.id ? alert.monitor.id.toString() : ""

Testing

  1. Create an alert without a monitor
  2. Confirm workspace notifications are sent without errors
*Originally created by @Eliaxie on 3/11/2026* Fixes #2348 ## Problem Alerts without monitors were causing workspace notifications (Slack/Teams) to crash with: ``` TypeError: Cannot read properties of null (reading 'id') at Service.getValuesBasedOnNotificationFor (WorkspaceNotificationRuleService.ts:2068:26) ``` ## Root Cause Regression introduced in commit 76ab3a8cd6 which removed optional chaining: ```diff - alert.monitor?.id!.toString() || "", + alert.monitor!.id!.toString() || "", ``` ## Solution Restore proper null handling: ```typescript alert.monitor?.id ? alert.monitor.id.toString() : "" ``` ## Testing 1. Create an alert without a monitor 2. Confirm workspace notifications are sent without errors
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/oneuptime#37