from authentik.blueprints.models import BlueprintInstance from authentik.blueprints.v1.importer import Importer failed = list(BlueprintInstance.objects.filter(enabled=True, path__startswith="custom/").exclude(status="successful").order_by("path")) if not failed: print("ok") else: for bp in failed: content = bp.retrieve() importer = Importer.from_string(content) valid, _ = importer.validate() if valid: importer.apply() bp.status = "successful" bp.save() still_failed = BlueprintInstance.objects.filter(enabled=True, path__startswith="custom/").exclude(status="successful") if still_failed.exists(): names = ", ".join(bp.name for bp in still_failed) raise Exception(f"Blueprints still failing: {names}") print("changed")