mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
tasks: better error message for Retry exceptions (#18235)
* tasks: better error message for Retry exceptions Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> * fixup Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space> --------- Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
committed by
GitHub
parent
00291a82bd
commit
4e8baeb8b5
@@ -8,6 +8,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_dramatiq_postgres.models import TaskBase, TaskState
|
||||
from dramatiq.errors import Retry
|
||||
|
||||
from authentik.events.logs import LogEvent
|
||||
from authentik.events.utils import sanitize_item
|
||||
@@ -103,11 +104,14 @@ class Task(InternallyManagedMixin, SerializerModel, TaskBase):
|
||||
cls, logger: str, log_level: TaskStatus, message: str | Exception, **attributes
|
||||
) -> LogEvent:
|
||||
if isinstance(message, Exception):
|
||||
exc = message
|
||||
attributes = {
|
||||
"exception": exception_to_dict(message),
|
||||
"exception": exception_to_dict(exc),
|
||||
**attributes,
|
||||
}
|
||||
message = str(message)
|
||||
if not message and isinstance(exc, Retry):
|
||||
message = "Task has encountered an error and will be retried"
|
||||
return LogEvent(
|
||||
message,
|
||||
logger=logger,
|
||||
|
||||
Reference in New Issue
Block a user