From a5b79afde14c4ed126065edae8dcf6e80c5d63ae Mon Sep 17 00:00:00 2001 From: Florent Chehab Date: Fri, 24 Jul 2026 12:07:44 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=B0=EF=B8=8F(summary)=20cleaned=20tasks?= =?UTF-8?q?=20failure=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code in task failure was assuming that the failure signal would be called on retry which is not the case. --- src/summary/summary/core/celery_worker.py | 102 ++++++++-------------- 1 file changed, 38 insertions(+), 64 deletions(-) diff --git a/src/summary/summary/core/celery_worker.py b/src/summary/summary/core/celery_worker.py index e12e17ca..fb65f71b 100644 --- a/src/summary/summary/core/celery_worker.py +++ b/src/summary/summary/core/celery_worker.py @@ -590,39 +590,26 @@ def handle_transcribe_v2_failed( ): """Handle the failure of transcribe_v2_task. - Tracks the failure event in analytics and, if the task - will not be retried, sends a failure webhook to the client. + Tracks the failure event in analytics and sends a failure webhook to the client. """ - autoretry_for = sender.autoretry_for - retries_remaining = sender.max_retries - sender.request.retries - 1 - - will_retry = retries_remaining > 0 and isinstance(exception, tuple(autoretry_for)) - - if will_retry: - logger.info( - "Transcribe task %s failed, %s retries left.", - task_id, - retries_remaining, - ) - else: - logger.error( - "Transcribe task %s failed, no more retries left, sending failure webhook.", - task_id, - ) - metadata_manager.capture( - task_id, - settings.posthog_transcript_failure, - {"exception_type": type(exception).__name__}, - ) - call_webhook_v2_task.apply_async( - args=[ - TranscribeWebhookFailurePayload( - job_id=task_id, - error_code="unknown_error", - ).model_dump(), - args[0]["tenant_id"], - ] - ) + logger.error( + "Transcribe task %s failed, no more retries left, sending failure webhook.", + task_id, + ) + metadata_manager.capture( + task_id, + settings.posthog_transcript_failure, + {"exception_type": type(exception).__name__}, + ) + call_webhook_v2_task.apply_async( + args=[ + TranscribeWebhookFailurePayload( + job_id=task_id, + error_code="unknown_error", + ).model_dump(), + args[0]["tenant_id"], + ] + ) @celery.task( @@ -699,36 +686,23 @@ def handle_summarize_v2_failed( ): """Handle the failure of summarize_v2_task. - Tracks the failure event in analytics and, if the task - will not be retried, sends a failure webhook to the client. + Tracks the failure event in analytics and sends a failure webhook to the client. """ - autoretry_for = sender.autoretry_for - retries_remaining = sender.max_retries - sender.request.retries - 1 - - will_retry = retries_remaining > 0 and isinstance(exception, tuple(autoretry_for)) - - if will_retry: - logger.info( - "Summary task %s failed, %s retries left.", - task_id, - retries_remaining, - ) - else: - logger.warn( - "Summary task %s failed, no more retries left, sending failure webhook.", - task_id, - ) - metadata_manager.capture( - task_id, - settings.posthog_summary_failure, - {"exception_type": type(exception).__name__}, - ) - call_webhook_v2_task.apply_async( - args=[ - SummarizeWebhookFailurePayload( - job_id=task_id, - error_code="unknown_error", - ).model_dump(), - args[0]["tenant_id"], - ] - ) + logger.warn( + "Summary task %s failed, no more retries left, sending failure webhook.", + task_id, + ) + metadata_manager.capture( + task_id, + settings.posthog_summary_failure, + {"exception_type": type(exception).__name__}, + ) + call_webhook_v2_task.apply_async( + args=[ + SummarizeWebhookFailurePayload( + job_id=task_id, + error_code="unknown_error", + ).model_dump(), + args[0]["tenant_id"], + ] + )