From 68b58fb73ca979748a5ef38e53b15250d94898e8 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 29 Dec 2022 21:55:17 +0100 Subject: [PATCH] blueprints: fix error when entry with state absent doesn't exist closes #4305 Signed-off-by: Jens Langhammer --- authentik/blueprints/tests/fixtures/state_absent.yaml | 6 ++++++ authentik/blueprints/v1/importer.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/authentik/blueprints/tests/fixtures/state_absent.yaml b/authentik/blueprints/tests/fixtures/state_absent.yaml index d73d929e2..c75d9e3df 100644 --- a/authentik/blueprints/tests/fixtures/state_absent.yaml +++ b/authentik/blueprints/tests/fixtures/state_absent.yaml @@ -5,3 +5,9 @@ entries: slug: "%(id)s" model: authentik_flows.flow state: absent + - identifiers: + name: "%(id)s" + expression: | + return True + model: authentik_policies_expression.expressionpolicy + state: absent diff --git a/authentik/blueprints/v1/importer.py b/authentik/blueprints/v1/importer.py index 7ba2468f4..6b32559ba 100644 --- a/authentik/blueprints/v1/importer.py +++ b/authentik/blueprints/v1/importer.py @@ -268,7 +268,7 @@ class Importer: self.logger.debug("updated model", model=model) elif state == BlueprintEntryDesiredState.ABSENT: instance: Optional[Model] = serializer.instance - if instance: + if instance.pk: instance.delete() self.logger.debug("deleted model", mode=instance) continue