[v10.4.x] Alerting: Fix panic in provisioning filter contacts by unknown name (#90440)
Alerting: Fix panic in provisioning filter contacts by unknown name (#83070)
(cherry picked from commit 87ab98ea95)
Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
This commit is contained in:
co-authored by
Matthew Jacobson
parent
6f64c51675
commit
9c9d47e99e
@@ -80,7 +80,7 @@ func (ecp *ContactPointService) GetContactPoints(ctx context.Context, q ContactP
|
||||
return nil, convertRecSvcErr(err)
|
||||
}
|
||||
grafanaReceivers := []*apimodels.GettableGrafanaReceiver{}
|
||||
if q.Name != "" {
|
||||
if q.Name != "" && len(res) > 0 {
|
||||
grafanaReceivers = res[0].GettableGrafanaReceivers.GrafanaManagedReceivers // we only expect one receiver group
|
||||
} else {
|
||||
for _, r := range res {
|
||||
|
||||
@@ -53,6 +53,15 @@ func TestContactPointService(t *testing.T) {
|
||||
require.Equal(t, "slack receiver", cps[0].Name)
|
||||
})
|
||||
|
||||
t.Run("service filters contact points by name, returns empty when no match", func(t *testing.T) {
|
||||
sut := createContactPointServiceSut(t, secretsService)
|
||||
|
||||
cps, err := sut.GetContactPoints(context.Background(), cpsQueryWithName(1, "unknown"), nil)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, cps, 0)
|
||||
})
|
||||
|
||||
t.Run("service stitches contact point into org's AM config", func(t *testing.T) {
|
||||
sut := createContactPointServiceSut(t, secretsService)
|
||||
newCp := createTestContactPoint()
|
||||
|
||||
Reference in New Issue
Block a user