diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt index 6eceb2aba..88e86509a 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportExecuteMonitorAction.kt @@ -135,6 +135,15 @@ class TransportExecuteMonitorAction @Inject constructor( val monitor = ScheduledJob.parse(xcp, getResponse.id, getResponse.version) as Monitor executeMonitor(monitor) } + } else { + actionListener.onFailure( + AlertingException.wrap( + OpenSearchStatusException( + "Monitor source is empty for id: ${execMonitorRequest.monitorId}", + RestStatus.NOT_FOUND + ) + ) + ) } } catch (e: Exception) { log.error("Failed to get monitor ${execMonitorRequest.monitorId} for execution", e)