Skip to content

Commit

Permalink
blueprints: fix validation error when using internal storage (#11654)
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <[email protected]>
  • Loading branch information
BeryJu authored Oct 11, 2024
1 parent d636002 commit fc7e784
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions authentik/blueprints/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ def validate_content(self, content: str) -> str:
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

Expand Down
2 changes: 1 addition & 1 deletion authentik/blueprints/tests/test_v1_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ def test_api_content(self):
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"]},
)
2 changes: 1 addition & 1 deletion authentik/blueprints/v1/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def validate(self, raise_validation_errors=False) -> tuple[bool, list[LogEvent]]
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,
Expand Down

0 comments on commit fc7e784

Please sign in to comment.