Improved error context (#12350)

- More useful error messaging if a task fails
This commit is contained in:
Oliver 2026-07-10 20:32:35 +10:00 committed by GitHub
parent a1787c659c
commit 29fa66a75f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -1465,11 +1465,15 @@ def after_failed_task(sender, instance: Task, created: bool, **kwargs):
# Create a new Error object associated with this failed task
# This will, in turn, trigger a notification to staff users via the Error post_save signal
message = f"Task '{instance.func} ({instance.pk})' failed after {n} attempts"
logger.error(message)
log_error(
'task_failure',
scope='worker',
error_name='Task Failure',
error_info=f"Task '{instance.pk}' failed after {n} attempts",
error_info=message,
error_data=str(instance.result) if instance.result else '',
)