From 74648df78615830288590f7de06f87421e9facbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simonyi=20Gerg=C5=91?= <28359278+gergosimonyi@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:10:07 +0000 Subject: [PATCH] core: add `None` check to a device's `extra_description` (#11904) --- authentik/core/api/devices.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/authentik/core/api/devices.py b/authentik/core/api/devices.py index 58040df8358f..cc8f77f5585b 100644 --- a/authentik/core/api/devices.py +++ b/authentik/core/api/devices.py @@ -1,5 +1,6 @@ """Authenticator Devices API Views""" +from django.utils.translation import gettext_lazy as _ from drf_spectacular.types import OpenApiTypes from drf_spectacular.utils import OpenApiParameter, extend_schema from rest_framework.fields import ( @@ -40,7 +41,11 @@ def get_type(self, instance: Device) -> str: def get_extra_description(self, instance: Device) -> str: """Get extra description""" if isinstance(instance, WebAuthnDevice): - return instance.device_type.description + return ( + instance.device_type.description + if instance.device_type + else _("Extra description not available") + ) if isinstance(instance, EndpointDevice): return instance.data.get("deviceSignals", {}).get("deviceModel") return ""