From 83a30f57f52f743ae0dc38d7d88085f65a9a5602 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Tue, 3 May 2016 15:56:02 -0400 Subject: [PATCH] Fixed JobTemplate migration when inventory is NULL JobTemplate.inventory can be NULL if the inventory was deleted. --- awx/main/migrations/_rbac.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/awx/main/migrations/_rbac.py b/awx/main/migrations/_rbac.py index 7f98e51acc..6f1ef0d4ad 100644 --- a/awx/main/migrations/_rbac.py +++ b/awx/main/migrations/_rbac.py @@ -142,7 +142,12 @@ def _discover_credentials(instances, cred, orgfunc): ''' orgs = defaultdict(list) for inst in instances: - orgs[orgfunc(inst)].append(inst) + try: + orgs[orgfunc(inst)].append(inst) + except AttributeError: + # JobTemplate.inventory can be NULL sometimes, eg when an inventory + # has been deleted. This protects against that. + pass if len(orgs) == 1: _update_credential_parents(orgfunc(instances[0]), cred)