Commit 22b9f46d authored by Sean McGivern's avatar Sean McGivern

Merge branch 'pl-notify-resilient' into 'master'

Make NotifyService more robust

See merge request gitlab-org/gitlab-ee!9362
parents 8a3a315f 33b5f0c4
...@@ -63,7 +63,7 @@ module Projects ...@@ -63,7 +63,7 @@ module Projects
end end
def gitlab_alert_id def gitlab_alert_id
alerts.first.dig('labels', 'gitlab_alert_id') alerts&.first&.dig('labels', 'gitlab_alert_id')
end end
def compare_token(expected, actual) def compare_token(expected, actual)
......
...@@ -158,6 +158,12 @@ describe Projects::Prometheus::Alerts::NotifyService do ...@@ -158,6 +158,12 @@ describe Projects::Prometheus::Alerts::NotifyService do
it_behaves_like 'no notifications' it_behaves_like 'no notifications'
end end
context 'with missing alerts' do
let(:payload) { { 'version' => '4' } }
it_behaves_like 'no notifications'
end
end end
private private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment