From 80adafdb484decbbea792e2a0699d3069f5c7f81 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 30 May 2021 16:22:13 +0200 Subject: [PATCH] admin: fix attribute error when loading old taskinfo Signed-off-by: Jens Langhammer --- authentik/admin/api/tasks.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/authentik/admin/api/tasks.py b/authentik/admin/api/tasks.py index dd6932cc2f..e425255a7b 100644 --- a/authentik/admin/api/tasks.py +++ b/authentik/admin/api/tasks.py @@ -30,6 +30,16 @@ class TaskSerializer(PassiveSerializer): ) messages = ListField(source="result.messages") + def to_representation(self, instance): + """When a new version of authentik adds fields to TaskInfo, + the API will fail with an AttributeError, as the classes + are pickled in cache. In that case, just delete the info""" + try: + return super().to_representation(instance) + except AttributeError: + self.instance.delete() + return {} + class TaskViewSet(ViewSet): """Read-only view set that returns all background tasks"""