From d5c21a375448f75db87c1ab3650518481f06ffd4 Mon Sep 17 00:00:00 2001 From: Ee Durbin Date: Sat, 26 Apr 2025 04:34:25 -0400 Subject: [PATCH] limit processing to events we actually listen for by default, the webhook handler from django-github-app processes and stores all events, even if they are not registered as actionable. since the Pull Request event on GitHub sends many events we are not interested in: > Pull request assigned, auto merge disabled, auto merge enabled, closed, converted to draft, demilestoned, dequeued, edited, enqueued, labeled, locked, milestoned, opened, ready for review, reopened, review request removed, review requested, synchronized, unassigned, unlabeled, or unlocked. This causes floods of events in situations like https://github.com/python/cpython/pull/132964 that we can skip processing for. --- clabot/github.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/clabot/github.py b/clabot/github.py index 4336cd4..b407417 100644 --- a/clabot/github.py +++ b/clabot/github.py @@ -18,8 +18,14 @@ class AsyncWebhookView(BaseAsyncWebhookView): async def post(self, request: HttpRequest) -> JsonResponse: event = self.get_event(request) - event_log = await EventLog.objects.acreate_from_event(event) - - await self.router.adispatch(event, None) - - return self.get_response(event_log) + found_callbacks = self.router.fetch(event) + if found_callbacks: + event_log = await EventLog.objects.acreate_from_event(event) + await self.router.adispatch(event, None) + return self.get_response(event_log) + else: + return JsonResponse( + { + "message": "ok", + } + )