From 20b8552005b93acd3a271970a669dd892c0e5952 Mon Sep 17 00:00:00 2001 From: Ran Mishael Date: Sun, 15 Sep 2024 09:54:02 +0200 Subject: [PATCH] do no crash process --- protocol/monitoring/alerting.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/protocol/monitoring/alerting.go b/protocol/monitoring/alerting.go index f9d3d8a5b7..99f429b1b5 100644 --- a/protocol/monitoring/alerting.go +++ b/protocol/monitoring/alerting.go @@ -354,12 +354,17 @@ func (al *Alerting) ProvidersAlerts(healthResults *HealthResults) { for provider, data := range healthResults.ProviderData { specId := provider.SpecId if al.allowedTimeGapVsReference > 0 { - latestBlock := healthResults.LatestBlocks[specId] + latestBlock, ok := healthResults.LatestBlocks[specId] + if !ok { + utils.LavaFormatError("Invalid spec id - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId}) + return + } if latestBlock > data.Block { gap := latestBlock - data.Block specHealthResult, ok := healthResults.Specs[specId] if !ok { - utils.LavaFormatFatal("Invalid specid - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId}) + utils.LavaFormatError("Invalid spec id - missing in healthResults", nil, utils.Attribute{Key: "specId", Value: specId}) + return } timeGap := time.Duration(gap*specHealthResult.AverageBlockTime) * time.Millisecond if timeGap > al.allowedTimeGapVsReference {