fix: guard against undefined conditions in MQTT monitor

Add check for monitor.conditions before calling fromMonitor() to
prevent JSON.parse(undefined) error when monitors don't have
conditions defined.
pull/6593/head
mkdev11 4 months ago
parent cf1391db6b
commit e22784aaea

@ -35,8 +35,8 @@ class MqttMonitorType extends MonitorType {
monitor.mqttCheckType = "keyword";
}
// Prepare conditions evaluation
const conditions = ConditionExpressionGroup.fromMonitor(monitor);
// Prepare conditions evaluation (only if monitor has conditions defined)
const conditions = monitor.conditions ? ConditionExpressionGroup.fromMonitor(monitor) : null;
const hasConditions = conditions && conditions.children && conditions.children.length > 0;
// Parse JSON if needed for conditions

Loading…
Cancel
Save