mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 01:47:35 -02:30
Fix 500 on unhandled group param type
This commit is contained in:
@@ -445,7 +445,8 @@ class LDAPGroupTypeField(fields.ChoiceField, DependsOnMixin):
|
|||||||
|
|
||||||
default_error_messages = {
|
default_error_messages = {
|
||||||
'type_error': _('Expected an instance of LDAPGroupType but got {input_type} instead.'),
|
'type_error': _('Expected an instance of LDAPGroupType but got {input_type} instead.'),
|
||||||
'missing_parameters': _('Missing required parameters in {dependency}.')
|
'missing_parameters': _('Missing required parameters in {dependency}.'),
|
||||||
|
'invalid_parameters': _('Invalid group_type parameters. Expected instance of dict but got {parameters_type} instead.')
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, choices=None, **kwargs):
|
def __init__(self, choices=None, **kwargs):
|
||||||
@@ -465,7 +466,6 @@ class LDAPGroupTypeField(fields.ChoiceField, DependsOnMixin):
|
|||||||
if not data:
|
if not data:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
params = self.get_depends_on() or {}
|
|
||||||
cls = find_class_in_modules(data)
|
cls = find_class_in_modules(data)
|
||||||
if not cls:
|
if not cls:
|
||||||
return None
|
return None
|
||||||
@@ -475,8 +475,16 @@ class LDAPGroupTypeField(fields.ChoiceField, DependsOnMixin):
|
|||||||
# Backwords compatability. Before AUTH_LDAP_GROUP_TYPE_PARAMS existed
|
# Backwords compatability. Before AUTH_LDAP_GROUP_TYPE_PARAMS existed
|
||||||
# MemberDNGroupType was the only group type, of the underlying lib, that
|
# MemberDNGroupType was the only group type, of the underlying lib, that
|
||||||
# took a parameter.
|
# took a parameter.
|
||||||
|
params = self.get_depends_on() or {}
|
||||||
params_sanitized = dict()
|
params_sanitized = dict()
|
||||||
for attr in inspect.getargspec(cls.__init__).args[1:]:
|
|
||||||
|
cls_args = inspect.getargspec(cls.__init__).args[1:]
|
||||||
|
|
||||||
|
if cls_args:
|
||||||
|
if not isinstance(params, dict):
|
||||||
|
self.fail('invalid_parameters', parameters_type=type(params))
|
||||||
|
|
||||||
|
for attr in cls_args:
|
||||||
if attr in params:
|
if attr in params:
|
||||||
params_sanitized[attr] = params[attr]
|
params_sanitized[attr] = params[attr]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user