tenants: handle all errors in default_locale

closes #3457

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-09-10 00:56:08 +02:00
parent 371f1878a8
commit aabb8af486

View file

@ -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: