From 4e63f0f215319037ca3212be45cd3c4acb71a660 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 13 Dec 2021 18:06:01 +0100 Subject: [PATCH] core: add fallback for missing sentry trace Signed-off-by: Jens Langhammer --- authentik/tenants/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/authentik/tenants/utils.py b/authentik/tenants/utils.py index cd3edc9c2..a59fd49c2 100644 --- a/authentik/tenants/utils.py +++ b/authentik/tenants/utils.py @@ -29,7 +29,10 @@ def get_tenant_for_request(request: HttpRequest) -> Tenant: def context_processor(request: HttpRequest) -> dict[str, Any]: """Context Processor that injects tenant object into every template""" tenant = getattr(request, "tenant", DEFAULT_TENANT) - trace = Hub.current.scope.span.to_traceparent() + trace = "" + span = Hub.current.scope.span + if span: + trace = span.to_traceparent() return { "tenant": tenant, "footer_links": CONFIG.y("footer_links"),