Commit 3ee8ed30 authored by Max Woolf's avatar Max Woolf

Handle event streaming when entity does not exist

Instead of raising an error, terminate the
worker execution instead and do not retry.
parent 0449172b
......@@ -15,6 +15,9 @@ module AuditEvents
def perform(audit_event_id)
audit_event = AuditEvent.find(audit_event_id)
return if audit_event.entity.nil?
group = group_entity(audit_event)
return if group.nil? # Do nothing if the event can't be resolved to a single group.
......
......@@ -97,5 +97,19 @@ RSpec.describe AuditEvents::AuditEventStreamingWorker do
worker.perform(event.id)
end
end
context 'when the entity is a NullEntity' do
let_it_be(:event) { create(:audit_event, :project_event) }
before do
event.entity_id = non_existing_record_id
end
it 'makes no HTTP calls' do
expect(Gitlab::HTTP).not_to receive(:post)
worker.perform(event.id)
end
end
end
end
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