From 50ca3dc7727668ac479b5e33f51d437dffd478a4 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Wed, 15 Dec 2021 15:11:13 +0100 Subject: [PATCH] core: fix error when attempting to provider from cached application closes #1940 Signed-off-by: Jens Langhammer --- authentik/core/models.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/authentik/core/models.py b/authentik/core/models.py index 136db1c14..33508aac8 100644 --- a/authentik/core/models.py +++ b/authentik/core/models.py @@ -278,7 +278,13 @@ class Application(PolicyBindingModel): """Get casted provider instance""" if not self.provider: return None - return Provider.objects.get_subclass(pk=self.provider.pk) + # if the Application class has been cache, self.provider is set + # but doing a direct query lookup will fail. + # In that case, just return None + try: + return Provider.objects.get_subclass(pk=self.provider.pk) + except Provider.DoesNotExist: + return None def __str__(self): return self.name