diff options
author | Sloane Hertel <19572925+s-hertel@users.noreply.github.com> | 2021-11-24 13:15:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-24 10:15:23 -0800 |
commit | 4079bc948bfc32cdbaee2ae2789eb5c81f2f3840 (patch) | |
tree | a4e7a8ca7e77a9733ce51c12cb5cf995fd80046a /lib | |
parent | a17581efa67c26771efa75b7197067b358de5625 (diff) | |
download | ansible-4079bc948bfc32cdbaee2ae2789eb5c81f2f3840.tar.gz |
Skip recursive suboption validation if sub_parameters is not a dict (#75635) (#76189)
* Skip recursive suboption validation if sub_parameters is not a dictionary
* Ensure sub parameter elements is a sequence to prevent iterating over string characters and causing duplicate error messages for the same param
(cherry picked from commit b5ed41edb34a387c560e172ee2928cc8ac9b4959)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansible/module_utils/common/parameters.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/ansible/module_utils/common/parameters.py b/lib/ansible/module_utils/common/parameters.py index 2624bb5092..8bba4d5f32 100644 --- a/lib/ansible/module_utils/common/parameters.py +++ b/lib/ansible/module_utils/common/parameters.py @@ -724,14 +724,17 @@ def _validate_sub_spec(argument_spec, parameters, prefix='', options_context=Non options_context.append(param) # Make sure we can iterate over the elements - if isinstance(parameters[param], dict): + if not isinstance(parameters[param], Sequence) or isinstance(parameters[param], string_types): elements = [parameters[param]] else: elements = parameters[param] for idx, sub_parameters in enumerate(elements): + no_log_values.update(set_fallbacks(sub_spec, sub_parameters)) + if not isinstance(sub_parameters, dict): errors.append(SubParameterTypeError("value of '%s' must be of type dict or list of dicts" % param)) + continue # Set prefix for warning messages new_prefix = prefix + param @@ -739,8 +742,6 @@ def _validate_sub_spec(argument_spec, parameters, prefix='', options_context=Non new_prefix += '[%d]' % idx new_prefix += '.' - no_log_values.update(set_fallbacks(sub_spec, sub_parameters)) - alias_warnings = [] alias_deprecations = [] try: |