Skip to content

Commit c3e3a95

Browse files
authored
AAP-51883 Fix unsafe assumption about org content type (ansible#814)
This fixes a server error This is due to, specifically, the registration of the `Team` model in galaxy_ng with no parent model. https://github.com/ansible/galaxy_ng/blob/5fce949deb374e1755029f7d9a5a6d109d031e69/galaxy_ng/app/models/__init__.py#L50-L59 Knowing that the parent model is null, you can read the traceback in a way that makes sense. The variable `team_parent_model` gets a value of `None`, which is 100% unexpected. At the end, `model` was _intended_ to be passed, but it has a value of `None`, which the method interprets as not being provided.
1 parent 5a52b1c commit c3e3a95

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ansible_base/rbac/permission_registry.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,13 @@ def content_type_model(self):
186186

187187
@cached_property
188188
def org_ct_id(self):
189-
team_parent_model = self.get_parent_model(self.team_model)
190-
return self.content_type_model.objects.get_for_model(team_parent_model).id
189+
# This should be safe to import at top of file because it is ansible_base.lib
190+
# but it is not because of issue:
191+
# https://github.com/ansible/django-ansible-base/issues/443
192+
from ansible_base.lib.utils.auth import get_organization_model
193+
194+
org_model = get_organization_model()
195+
return self.content_type_model.objects.get_for_model(org_model).id
191196

192197
@property
193198
def permission_qs(self):

0 commit comments

Comments
 (0)