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

[AnsibleArgSpecValidator] remove empty keys from task args before validation #313

Closed

Conversation

NilashishC
Copy link
Contributor

SUMMARY
  • When HAS_ANSIBLE_ARG_SPEC_VALIDATOR is False, we fallback to creating a MonkeyModule class and use that to leverage AnsibleModule class's argspec validation logic. However, the task args passed for validation do not have empty keys removed from them before this is done. This results in incorrect validation failures.

  • remove_empties method is already defined in ansible.netcommon, but netcommon depends on utils and not vice-versa, we cannot import that method in here. So, the alternative was to copy it over for now.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

argspec_validate.py

@NilashishC
Copy link
Contributor Author

Hmm, looks like this probably cannot be added here because of how some plugins (and their tests) are designed to work.

  TASK [utils_to_paths : Test filter and lookup plugin with empty list and mapping] ***
  task path: /home/runner/collections/ansible_collections/ansible/utils/tests/integration/targets/utils_to_paths/tasks/empty_members.yaml:14
  fatal: [localhost]: FAILED! => {
      "msg": "missing required arguments: var"
  }

Copy link
Contributor

@ashwini-mhatre ashwini-mhatre self-requested a review November 27, 2023 11:42
Copy link
Contributor

@ashwini-mhatre
Copy link
Contributor

@NilashishC Could you please add some tests if possible.otherwise LGTM

Copy link
Contributor

@NilashishC NilashishC closed this Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants