ansible-collections / news-for-maintainers

Announcements of changes impacting collection contributors and maintainers
26 stars 4 forks source link

ansible-test devel validate-modules test has stricter check for matching `default` between argument spec and documentation #25

Closed felixfontein closed 7 months ago

felixfontein commented 1 year ago

In ansible-test from ansible-core's devel branch, https://github.com/ansible/ansible/pull/79267 updated the validate-modules sanity test. Now the check whether default for argument spec and documentation no longer treats falsy values that are not False as None.

This affects default values of 0, [], {}, or ''. If documentation or the argument spec uses one of these, and other other one another - or None -, the sanity check did not flag this in the past.

sshnaidm commented 1 year ago

@felixfontein something is wrong with this test. I fixed a module with defaults 0, but ansible-test can't recongnize it: https://review.opendev.org/c/openstack/ansible-collections-openstack/+/863267/3/plugins/modules/image.py

   min_disk:
     description:
        - The minimum disk space (in GB) required to boot this image
     type: int
     default: 0
   min_ram:
     description:
        - The minimum ram (in MB) required to boot this image
     type: int
     default: 0

and:

        min_disk=dict(type='int', default=0),
        min_ram=dict(type='int', default=0),

But I still have an error:

ERROR: Found 2 validate-modules issue(s) which need to be resolved:
ERROR: plugins/modules/image.py:0:0: doc-default-does-not-match-spec: Argument 'min_disk' in argument_spec defines default as (None) but documentation defines default as (0)
ERROR: plugins/modules/image.py:0:0: doc-default-does-not-match-spec: Argument 'min_ram' in argument_spec defines default as (None) but documentation defines default as (0)

Perhaps it's a bug with processing an integer 0?