summaryrefslogtreecommitdiffstats
path: root/tools/scripts
diff options
context:
space:
mode:
authorJeff Bradberry <jeff.bradberry@gmail.com>2024-05-06 19:47:35 +0200
committerJeff Bradberry <jeff.bradberry@gmail.com>2024-06-10 22:36:22 +0200
commitd675207f997fd5b82e0b1e0e06be4eb89ebd8f7e (patch)
tree594d7bee47ca3d5d387ee3d3a4cac14cf5ca6528 /tools/scripts
parentGraph out only the parent/child chains from a given Role (diff)
downloadawx-d675207f997fd5b82e0b1e0e06be4eb89ebd8f7e.tar.xz
awx-d675207f997fd5b82e0b1e0e06be4eb89ebd8f7e.zip
Handle the case where a resource points to a Role which isn't in the db
Diffstat (limited to 'tools/scripts')
-rw-r--r--tools/scripts/ig-hotfix/role_check.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/scripts/ig-hotfix/role_check.py b/tools/scripts/ig-hotfix/role_check.py
index ec8511dfd9..d290d9c15c 100644
--- a/tools/scripts/ig-hotfix/role_check.py
+++ b/tools/scripts/ig-hotfix/role_check.py
@@ -22,7 +22,13 @@ for ct in ContentType.objects.order_by('id'):
for f in cls._meta.fields:
if not isinstance(f, ImplicitRoleField):
continue
- r = getattr(obj, f.name, None)
+ r_id = getattr(obj, f'{f.name}_id', None)
+ try:
+ r = getattr(obj, f.name, None)
+ except Role.DoesNotExist:
+ sys.stderr.write(f"{cls} id={obj.id} {f.name} points to Role id={r_id}, which is not in the database.")
+ crosslinked[ct.id][obj.id][f'{f.name}_id'] = None
+ continue
if not r:
sys.stderr.write(f"{cls} id={obj.id} {f.name} does not have a Role object\n")
crosslinked[ct.id][obj.id][f'{f.name}_id'] = None