From dc8f7b38e636799c4e240e0aea14fcf317500956 Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Fri, 21 Jun 2019 08:39:12 -0400 Subject: [PATCH] Check that provider['options'] is a dictionary in validate-modules (#58078) --- test/sanity/validate-modules/main.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/sanity/validate-modules/main.py b/test/sanity/validate-modules/main.py index 5e3de8626bd..4505e1b69e0 100755 --- a/test/sanity/validate-modules/main.py +++ b/test/sanity/validate-modules/main.py @@ -1177,10 +1177,17 @@ class ModuleValidator(Validator): deprecated_args_from_argspec.add(arg) deprecated_args_from_argspec.update(data.get('aliases', [])) if arg == 'provider' and self.object_path.startswith('lib/ansible/modules/network/'): - # Record provider options from network modules, for later comparison - for provider_arg, provider_data in data.get('options', {}).items(): - provider_args.add(provider_arg) - provider_args.update(provider_data.get('aliases', [])) + if data.get('options') and not isinstance(data.get('options'), dict): + self.reporter.error( + path=self.object_path, + code=331, + msg="Argument 'options' in argument_spec['provider'] must be a dictionary/hash when used", + ) + else: + # Record provider options from network modules, for later comparison + for provider_arg, provider_data in data.get('options', {}).items(): + provider_args.add(provider_arg) + provider_args.update(provider_data.get('aliases', [])) if data.get('required') and data.get('default', object) != object: self.reporter.error(