Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate types before asserting lengths #56882

Merged
merged 1 commit into from May 23, 2019
Merged

Conversation

sivel
Copy link
Member

@sivel sivel commented May 23, 2019

SUMMARY

Validate types before asserting lengths

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

test/sanity/validate-modules/schema.py

ADDITIONAL INFORMATION

before

00:58 Traceback (most recent call last):
00:58   File "test/sanity/validate-modules/validate-modules", line 846, in _validate_docs_schema
00:58     schema(doc)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/schema_builder.py", line 267, in __call__
00:58     return self._compiled([], data)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/schema_builder.py", line 589, in validate_dict
00:58     return base_validate(path, iteritems(data), out)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/schema_builder.py", line 381, in validate_mapping
00:58     cval = cvalue(key_path, value)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/validators.py", line 204, in _run
00:58     return self._exec(self._compiled, value, path)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/validators.py", line 284, in _exec
00:58     v = func(path, v)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/validators.py", line 204, in _run
00:58     return self._exec(self._compiled, value, path)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/validators.py", line 249, in _exec
00:58     return func(path, v)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/schema_builder.py", line 630, in validate_sequence
00:58     cval = validate(index_path, value)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/schema_builder.py", line 811, in validate_callable
00:58     return schema(data)
00:58   File "/usr/local/lib/python3.6/dist-packages/voluptuous/validators.py", line 601, in __call__
00:58     if self.min is not None and len(v) < self.min:
00:58 TypeError: object of type 'bool' has no len()
00:58 
00:58 During handling of the above exception, another exception occurred:
00:58 
00:58 Traceback (most recent call last):
00:58   File "test/sanity/validate-modules/validate-modules", line 1745, in <module>
00:58     main()
00:58   File "test/sanity/validate-modules/validate-modules", line 1644, in main
00:58     mv.validate()
00:58   File "test/sanity/validate-modules/validate-modules", line 1525, in validate
00:58     self._validate_ansible_module_call(docs)
00:58   File "test/sanity/validate-modules/validate-modules", line 1142, in _validate_ansible_module_call
00:58     self._validate_docs_schema(kwargs, ansible_module_kwargs_schema, 'AnsibleModule', 332)
00:58   File "test/sanity/validate-modules/validate-modules", line 848, in _validate_docs_schema
00:58     for error in e.errors:
00:58 AttributeError: 'TypeError' object has no attribute 'errors'

after

lib/ansible/modules/cloud/memset/memset_memstore_user.py:0:0: E332 AnsibleModule.required_if.0: expected list @ data['required_if'][0]. Got 'update_password'
lib/ansible/modules/cloud/memset/memset_memstore_user.py:0:0: E332 AnsibleModule.required_if.1: expected list @ data['required_if'][1]. Got True

@sivel sivel requested a review from mattclay May 23, 2019 21:07
@ansibot
Copy link
Contributor

ansibot commented May 23, 2019

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. traceback This issue/PR includes a traceback. labels May 23, 2019
@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label May 23, 2019
@sivel sivel merged commit 9c5b721 into ansible:devel May 23, 2019
sivel added a commit to sivel/ansible that referenced this pull request May 23, 2019
(cherry picked from commit 9c5b721)

Co-authored-by: Matt Martz <matt@sivel.net>
sivel added a commit to sivel/ansible that referenced this pull request May 23, 2019
(cherry picked from commit 9c5b721)

Co-authored-by: Matt Martz <matt@sivel.net>
sivel added a commit to sivel/ansible that referenced this pull request May 23, 2019
(cherry picked from commit 9c5b721)

Co-authored-by: Matt Martz <matt@sivel.net>
abadger pushed a commit that referenced this pull request May 24, 2019
(cherry picked from commit 9c5b721)

Co-authored-by: Matt Martz <matt@sivel.net>
abadger pushed a commit that referenced this pull request May 24, 2019
(cherry picked from commit 9c5b721)

Co-authored-by: Matt Martz <matt@sivel.net>
abadger pushed a commit that referenced this pull request May 26, 2019
(cherry picked from commit 9c5b721)

Co-authored-by: Matt Martz <matt@sivel.net>
@ansible ansible locked and limited conversation to collaborators Aug 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants