From ce2ce38b596c5d3ad4d91ba4d860b207b8712766 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 23 Aug 2022 19:21:57 +0200 Subject: [PATCH] blueprints: improve error messages Signed-off-by: Jens Langhammer --- authentik/blueprints/v1/importer.py | 8 +++++--- authentik/blueprints/v1/tasks.py | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/authentik/blueprints/v1/importer.py b/authentik/blueprints/v1/importer.py index 6c9744aa5..6792b2bc0 100644 --- a/authentik/blueprints/v1/importer.py +++ b/authentik/blueprints/v1/importer.py @@ -169,7 +169,9 @@ class Importer: serializer_kwargs["instance"] = model_instance serializer_kwargs["partial"] = True else: - self.logger.debug("initialise new instance", model=model, **updated_identifiers) + self.logger.debug( + "initialised new serializer instance", model=model, **updated_identifiers + ) model_instance = model() # pk needs to be set on the model instance otherwise a new one will be generated if "pk" in updated_identifiers: @@ -215,7 +217,7 @@ class Importer: try: serializer = self._validate_single(entry) except EntryInvalidError as exc: - self.logger.warning("entry invalid", entry=entry, error=exc) + self.logger.warning(f"entry invalid: {exc}", entry=entry, error=exc) return False model = serializer.save() @@ -239,7 +241,7 @@ class Importer: ): successful = self._apply_models() if not successful: - self.logger.debug("blueprint validation failed") + self.logger.debug("Blueprint validation failed") for log in logs: self.logger.debug(**log) self.__import = orig_import diff --git a/authentik/blueprints/v1/tasks.py b/authentik/blueprints/v1/tasks.py index 9cc4ab0da..f685d7ef7 100644 --- a/authentik/blueprints/v1/tasks.py +++ b/authentik/blueprints/v1/tasks.py @@ -6,6 +6,7 @@ from typing import Optional from dacite import from_dict from django.db import DatabaseError, InternalError, ProgrammingError +from django.utils.text import slugify from django.utils.timezone import now from django.utils.translation import gettext_lazy as _ from structlog.stdlib import get_logger @@ -134,10 +135,10 @@ def check_blueprint_v1_file(blueprint: BlueprintFile): ) def apply_blueprint(self: MonitoredTask, instance_pk: str): """Apply single blueprint""" - self.set_uid(instance_pk) self.save_on_success = False try: instance: BlueprintInstance = BlueprintInstance.objects.filter(pk=instance_pk).first() + self.set_uid(slugify(instance.name)) if not instance or not instance.enabled: return blueprint_content = instance.retrieve()