From 0e87e97820166e4442d66e6ca8825c1403f73e18 Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Mon, 6 May 2024 10:31:17 -0400 Subject: [PATCH] Check for a broken ContentType -> model and log and skip Apparently this has happened to a customer, per Nate Becker. --- tools/scripts/ig-hotfix/role_check.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/scripts/ig-hotfix/role_check.py b/tools/scripts/ig-hotfix/role_check.py index f5d902340f..ec8511dfd9 100644 --- a/tools/scripts/ig-hotfix/role_check.py +++ b/tools/scripts/ig-hotfix/role_check.py @@ -13,6 +13,9 @@ orphaned_roles = [] for ct in ContentType.objects.order_by('id'): cls = ct.model_class() + if cls is None: + sys.stderr.write(f"{ct!r} does not have a corresponding model class in the codebase. Skipping.\n") + continue if not any(isinstance(f, ImplicitRoleField) for f in cls._meta.fields): continue for obj in cls.objects.all():