Alerting: Include rule uid, title, namespace in unique constraint errors (#82011)
* Alerting: Include rule_uid, title, namespace_uid in unique constraint errors
This commit is contained in:
@@ -841,11 +841,11 @@ func TestIntegrationAlertRuleConflictingTitle(t *testing.T) {
|
||||
rulesWithUID.Rules = append(rulesWithUID.Rules, rules.Rules[0]) // Create new copy of first rule.
|
||||
|
||||
_, status, body := apiClient.PostRulesGroupWithStatus(t, "folder1", &rulesWithUID)
|
||||
assert.Equal(t, http.StatusInternalServerError, status)
|
||||
assert.Equal(t, http.StatusConflict, status)
|
||||
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal([]byte(body), &res))
|
||||
require.Equal(t, "failed to update rule group: failed to add rules: a conflicting alert rule is found: rule title under the same organisation and folder should be unique", res["message"])
|
||||
require.Contains(t, res["message"], ngmodels.ErrAlertRuleUniqueConstraintViolation.Error())
|
||||
})
|
||||
|
||||
t.Run("trying to update an alert to the title of an existing alert in the same folder should fail", func(t *testing.T) {
|
||||
@@ -853,11 +853,11 @@ func TestIntegrationAlertRuleConflictingTitle(t *testing.T) {
|
||||
rulesWithUID.Rules[1].GrafanaManagedAlert.Title = "AlwaysFiring"
|
||||
|
||||
_, status, body := apiClient.PostRulesGroupWithStatus(t, "folder1", &rulesWithUID)
|
||||
assert.Equal(t, http.StatusInternalServerError, status)
|
||||
assert.Equal(t, http.StatusConflict, status)
|
||||
|
||||
var res map[string]any
|
||||
require.NoError(t, json.Unmarshal([]byte(body), &res))
|
||||
require.Equal(t, "failed to update rule group: failed to update rules: a conflicting alert rule is found: rule title under the same organisation and folder should be unique", res["message"])
|
||||
require.Contains(t, res["message"], ngmodels.ErrAlertRuleUniqueConstraintViolation.Error())
|
||||
})
|
||||
|
||||
t.Run("trying to create alert with same title under another folder should succeed", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user