From ca2fce8be2343575925ed881b615120bb67d5fc1 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 23 Aug 2022 18:48:01 +0200 Subject: [PATCH] blueprints: always set metadata when attempting to apply Signed-off-by: Jens Langhammer --- authentik/blueprints/v1/tasks.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/authentik/blueprints/v1/tasks.py b/authentik/blueprints/v1/tasks.py index 9ad6810a42..ccfdcc2216 100644 --- a/authentik/blueprints/v1/tasks.py +++ b/authentik/blueprints/v1/tasks.py @@ -125,8 +125,6 @@ def check_blueprint_v1_file(blueprint: BlueprintFile): ) instance.save() if instance.last_applied_hash != blueprint.hash: - instance.metadata = asdict(blueprint.meta) if blueprint.meta else {} - instance.save() apply_blueprint.delay(instance.pk.hex) @@ -160,7 +158,6 @@ def apply_blueprint(self: MonitoredTask, instance_pk: str): instance.status = BlueprintInstanceStatus.SUCCESSFUL instance.last_applied_hash = file_hash instance.last_applied = now() - instance.save() self.set_status(TaskResult(TaskResultStatus.SUCCESSFUL)) except ( DatabaseError, @@ -170,5 +167,7 @@ def apply_blueprint(self: MonitoredTask, instance_pk: str): BlueprintRetrievalFailed, ) as exc: instance.status = BlueprintInstanceStatus.ERROR - instance.save() self.set_status(TaskResult(TaskResultStatus.ERROR).with_error(exc)) + finally: + instance.metadata = asdict(importer.blueprint.metadata) + instance.save()