From aabb8af486e34d9170f57c8d2394b3d2148a51ee Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 10 Sep 2022 00:56:08 +0200 Subject: [PATCH] tenants: handle all errors in default_locale closes #3457 Signed-off-by: Jens Langhammer --- authentik/tenants/models.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/authentik/tenants/models.py b/authentik/tenants/models.py index f211b830d..4f99b0b42 100644 --- a/authentik/tenants/models.py +++ b/authentik/tenants/models.py @@ -4,12 +4,15 @@ from uuid import uuid4 from django.db import models from django.utils.translation import gettext_lazy as _ from rest_framework.serializers import Serializer +from structlog.stdlib import get_logger from authentik.crypto.models import CertificateKeyPair from authentik.flows.models import Flow from authentik.lib.models import SerializerModel from authentik.lib.utils.time import timedelta_string_validator +LOGGER = get_logger() + class Tenant(SerializerModel): """Single tenant""" @@ -75,7 +78,12 @@ class Tenant(SerializerModel): @property def default_locale(self) -> str: """Get default locale""" - return self.attributes.get("settings", {}).get("locale", "") + try: + return self.attributes.get("settings", {}).get("locale", "") + # pylint: disable=broad-except + except Exception as exc: + LOGGER.warning("Failed to get default locale", exc=exc) + return "" def __str__(self) -> str: if self.default: