From 45c5a443fbb7daa378cb0013a35f77fda6a94d76 Mon Sep 17 00:00:00 2001 From: Florent Chehab Date: Thu, 2 Apr 2026 22:54:10 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(summary)=20fix=20failure=20webhook?= =?UTF-8?q?=20notification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Computation was off by 1. Also improve the logging. --- CHANGELOG.md | 1 + src/summary/summary/core/celery_worker.py | 35 +++++++++++++++++------ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2efddd1..364194c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to - ⬆️(dependencies) update vite to v7.3.2 [SECURITY] - ⬆️(dependencies) update django to v5.2.13 [SECURITY] - 🔒(backend) rely on backend to allow participant update their metadata +- 🐛(summary) fix failure webhook notification #1233 ## [1.13.0] - 2026-03-31 diff --git a/src/summary/summary/core/celery_worker.py b/src/summary/summary/core/celery_worker.py index f3872e55..fdd2c499 100644 --- a/src/summary/summary/core/celery_worker.py +++ b/src/summary/summary/core/celery_worker.py @@ -52,7 +52,6 @@ metadata_manager = MetadataManager() logger = get_task_logger(__name__) - celery = Celery( __name__, broker=settings.celery_broker_url, @@ -497,13 +496,22 @@ def handle_transcribe_v2_failed( This function is triggered when the transcribe_v2_task fails. It sends a webhook failure payload to notify the client of the failure. """ - task = sender - # If retries are exhausted: - if task.request.retries >= task.max_retries: + n_retries_left = sender.max_retries - sender.request.retries - 1 + if n_retries_left > 0: + logger.info( + "Transcribe task %s failed, %s retries left.", + task_id, + n_retries_left, + ) + else: + logger.warn( + "Transcribe task %s failed, no more retries left, sending failure webhook.", + task_id, + ) call_webhook_v2_task.apply_async( args=[ TranscribeWebhookFailurePayload( - job_id=task.id, + job_id=task_id, error_code="unknown_error", ).model_dump(), args[0]["tenant_id"], @@ -562,13 +570,22 @@ def handle_summarize_v2_failed( This function is triggered when the summarize_v2_task fails. It sends a webhook failure payload to notify the client of the failure. """ - task = sender - # If retries are exhausted: - if task.request.retries >= task.max_retries: + n_retries_left = sender.max_retries - sender.request.retries - 1 + if n_retries_left > 0: + logger.info( + "Summary task %s failed, %s retries left.", + task_id, + n_retries_left, + ) + else: + logger.warn( + "Summary task %s failed, no more retries left, sending failure webhook.", + task_id, + ) call_webhook_v2_task.apply_async( args=[ SummarizeWebhookFailurePayload( - job_id=task.id, + job_id=task_id, error_code="unknown_error", ).model_dump(), args[0]["tenant_id"],