From fc7e78444f63f59bd5a090f6d0412645209796c3 Mon Sep 17 00:00:00 2001 From: "Jens L." Date: Fri, 11 Oct 2024 14:25:38 +0200 Subject: [PATCH] blueprints: fix validation error when using internal storage (#11654) Signed-off-by: Jens Langhammer --- authentik/blueprints/api.py | 6 ++++-- authentik/blueprints/tests/test_v1_api.py | 2 +- authentik/blueprints/v1/importer.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/authentik/blueprints/api.py b/authentik/blueprints/api.py index 993121e705..c4cc098df3 100644 --- a/authentik/blueprints/api.py +++ b/authentik/blueprints/api.py @@ -51,9 +51,11 @@ class BlueprintInstanceSerializer(ModelSerializer): context = self.instance.context if self.instance else {} valid, logs = Importer.from_string(content, context).validate() if not valid: - text_logs = "\n".join([x["event"] for x in logs]) raise ValidationError( - _("Failed to validate blueprint: {logs}".format_map({"logs": text_logs})) + [ + _("Failed to validate blueprint"), + *[f"- {x.event}" for x in logs], + ] ) return content diff --git a/authentik/blueprints/tests/test_v1_api.py b/authentik/blueprints/tests/test_v1_api.py index 681260d690..f4e6d0fb0c 100644 --- a/authentik/blueprints/tests/test_v1_api.py +++ b/authentik/blueprints/tests/test_v1_api.py @@ -78,5 +78,5 @@ class TestBlueprintsV1API(APITestCase): self.assertEqual(res.status_code, 400) self.assertJSONEqual( res.content.decode(), - {"content": ["Failed to validate blueprint: Invalid blueprint version"]}, + {"content": ["Failed to validate blueprint", "- Invalid blueprint version"]}, ) diff --git a/authentik/blueprints/v1/importer.py b/authentik/blueprints/v1/importer.py index 4f3d4f762b..88a0569b42 100644 --- a/authentik/blueprints/v1/importer.py +++ b/authentik/blueprints/v1/importer.py @@ -429,7 +429,7 @@ class Importer: orig_import = deepcopy(self._import) if self._import.version != 1: self.logger.warning("Invalid blueprint version") - return False, [{"event": "Invalid blueprint version"}] + return False, [LogEvent("Invalid blueprint version", log_level="warning", logger=None)] with ( transaction_rollback(), capture_logs() as logs,