mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 07:35:45 -06:00
Alerting: Fix panic in provisioning filter contacts by unknown name (#83070)
This commit is contained in:
parent
b56f6ed0dc
commit
87ab98ea95
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user