Show field instead of value (#59926)

* Show argument name vs value on failed conversion

  generally more useful to user as they might set values indirectly

* clog
pull/67664/head
Brian Coca 6 years ago committed by GitHub
parent 542d1b98ff
commit 00b70bf36a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- An invalid value is hard to track down if you don't know where it came from, return field name instead.

@ -65,7 +65,7 @@ def _return_datastructure_name(obj):
elif isinstance(obj, tuple(list(integer_types) + [float])):
yield to_native(obj, nonstring='simplerepr')
else:
raise TypeError('Unknown parameter type: %s, %s' % (type(obj), obj))
raise TypeError('Unknown parameter type: %s' % (type(obj)))
def list_no_log_values(argument_spec, params):
@ -86,7 +86,10 @@ def list_no_log_values(argument_spec, params):
no_log_object = params.get(arg_name, None)
if no_log_object:
no_log_values.update(_return_datastructure_name(no_log_object))
try:
no_log_values.update(_return_datastructure_name(no_log_object))
except TypeError as e:
raise TypeError('Failed to convert "%s": %s' % (arg_name, to_native(e)))
# Get no_log values from suboptions
sub_argument_spec = arg_opts.get('options')

Loading…
Cancel
Save