blueprints: fix validation error when using internal storage (#11654)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		@ -51,9 +51,11 @@ class BlueprintInstanceSerializer(ModelSerializer):
 | 
				
			|||||||
        context = self.instance.context if self.instance else {}
 | 
					        context = self.instance.context if self.instance else {}
 | 
				
			||||||
        valid, logs = Importer.from_string(content, context).validate()
 | 
					        valid, logs = Importer.from_string(content, context).validate()
 | 
				
			||||||
        if not valid:
 | 
					        if not valid:
 | 
				
			||||||
            text_logs = "\n".join([x["event"] for x in logs])
 | 
					 | 
				
			||||||
            raise ValidationError(
 | 
					            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
 | 
					        return content
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -78,5 +78,5 @@ class TestBlueprintsV1API(APITestCase):
 | 
				
			|||||||
        self.assertEqual(res.status_code, 400)
 | 
					        self.assertEqual(res.status_code, 400)
 | 
				
			||||||
        self.assertJSONEqual(
 | 
					        self.assertJSONEqual(
 | 
				
			||||||
            res.content.decode(),
 | 
					            res.content.decode(),
 | 
				
			||||||
            {"content": ["Failed to validate blueprint: Invalid blueprint version"]},
 | 
					            {"content": ["Failed to validate blueprint", "- Invalid blueprint version"]},
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
				
			|||||||
@ -429,7 +429,7 @@ class Importer:
 | 
				
			|||||||
        orig_import = deepcopy(self._import)
 | 
					        orig_import = deepcopy(self._import)
 | 
				
			||||||
        if self._import.version != 1:
 | 
					        if self._import.version != 1:
 | 
				
			||||||
            self.logger.warning("Invalid blueprint version")
 | 
					            self.logger.warning("Invalid blueprint version")
 | 
				
			||||||
            return False, [{"event": "Invalid blueprint version"}]
 | 
					            return False, [LogEvent("Invalid blueprint version", log_level="warning", logger=None)]
 | 
				
			||||||
        with (
 | 
					        with (
 | 
				
			||||||
            transaction_rollback(),
 | 
					            transaction_rollback(),
 | 
				
			||||||
            capture_logs() as logs,
 | 
					            capture_logs() as logs,
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user