From 27b85e732db68e62b0d76366b9453508b06fdaac Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 20 Jun 2018 21:35:49 +0530 Subject: [PATCH] Argument spec must be dict/hash (#40858) validate-modules should fail when argument is not dict/hash. Signed-off-by: Abhijeet Kasurde --- docs/docsite/rst/dev_guide/testing_validate-modules.rst | 1 + test/sanity/validate-modules/main.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/docsite/rst/dev_guide/testing_validate-modules.rst b/docs/docsite/rst/dev_guide/testing_validate-modules.rst index c56169832ab..2c751e99498 100644 --- a/docs/docsite/rst/dev_guide/testing_validate-modules.rst +++ b/docs/docsite/rst/dev_guide/testing_validate-modules.rst @@ -117,6 +117,7 @@ Errors 328 Choices value from the documentation is not compatible with type defined in the argument_spec 329 Default value from the argument_spec is not compatible with type defined in the argument_spec 330 Choices value from the argument_spec is not compatible with type defined in the argument_spec + 331 argument in argument_spec must be a dictionary/hash when used .. --------- ------------------- **4xx** **Syntax** diff --git a/test/sanity/validate-modules/main.py b/test/sanity/validate-modules/main.py index 0524df22a10..e60c963b89a 100755 --- a/test/sanity/validate-modules/main.py +++ b/test/sanity/validate-modules/main.py @@ -1036,6 +1036,13 @@ class ModuleValidator(Validator): args_from_argspec = set() deprecated_args_from_argspec = set() for arg, data in spec.items(): + if not isinstance(data, dict): + self.reporter.error( + path=self.object_path, + code=331, + msg="argument '%s' in argument_spec must be a dictionary/hash when used" % arg, + ) + continue if not data.get('removed_in_version', None): args_from_argspec.add(arg) args_from_argspec.update(data.get('aliases', []))