From 9cebf0fce572fc722553145e4c64cf622eaa2a7c Mon Sep 17 00:00:00 2001 From: Gali Alykoff Date: Wed, 28 Aug 2019 13:48:43 +0300 Subject: [PATCH 1/2] Improve message of notification json error --- pkg/services/alerting/rule.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/alerting/rule.go b/pkg/services/alerting/rule.go index af33078b20998..4ad1b4a038910 100644 --- a/pkg/services/alerting/rule.go +++ b/pkg/services/alerting/rule.go @@ -141,7 +141,7 @@ func NewRuleFromDBAlert(ruleDef *models.Alert) (*Rule, error) { } else { uid, err := jsonModel.Get("uid").String() if err != nil { - return nil, ValidationError{Reason: "Neither id nor uid is specified, " + err.Error(), DashboardID: model.DashboardID, AlertID: model.ID, PanelID: model.PanelID} + return nil, ValidationError{Reason: "Neither id nor uid is specified in 'notifications' block, " + err.Error(), DashboardID: model.DashboardID, AlertID: model.ID, PanelID: model.PanelID} } model.Notifications = append(model.Notifications, uid) } From 3a5881e6836fc8c72dfd99af297732e6b4a958bc Mon Sep 17 00:00:00 2001 From: Gali Alykoff Date: Wed, 28 Aug 2019 13:53:00 +0300 Subject: [PATCH 2/2] Fix test after change error message --- pkg/services/alerting/rule_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/alerting/rule_test.go b/pkg/services/alerting/rule_test.go index 853fb5d17b5cf..84ce6fbfe3db0 100644 --- a/pkg/services/alerting/rule_test.go +++ b/pkg/services/alerting/rule_test.go @@ -179,7 +179,7 @@ func TestAlertRuleModel(t *testing.T) { _, err := NewRuleFromDBAlert(alert) So(err, ShouldNotBeNil) - So(err.Error(), ShouldEqual, "Alert validation error: Neither id nor uid is specified, type assertion to string failed AlertId: 1 PanelId: 1 DashboardId: 1") + So(err.Error(), ShouldEqual, "Alert validation error: Neither id nor uid is specified in 'notifications' block, type assertion to string failed AlertId: 1 PanelId: 1 DashboardId: 1") }) }) }