diff --git a/changelogs/fragments/315-ordered-names.yml b/changelogs/fragments/315-ordered-names.yml index 57101ed4..5153420c 100644 --- a/changelogs/fragments/315-ordered-names.yml +++ b/changelogs/fragments/315-ordered-names.yml @@ -1,5 +1,5 @@ minor_changes: - - "acme_certificate - the ``subject`` and ``issuer`` fields in in the ``select_chain`` entries are now stricter validated (https://github.com/ansible-collections/community.crypto/pull/316)." + - "acme_certificate - the ``subject`` and ``issuer`` fields in in the ``select_chain`` entries are now more strictly validated (https://github.com/ansible-collections/community.crypto/pull/316)." - "openssl_csr, openssl_csr_pipe - there is now stricter validation of the values of the ``subject`` option (https://github.com/ansible-collections/community.crypto/pull/316)." - "openssl_csr, openssl_csr_pipe - provide a new ``subject_ordered`` option if the order of the components in the subject is of importance (https://github.com/ansible-collections/community.crypto/issues/291, https://github.com/ansible-collections/community.crypto/pull/316)." - "x509_crl - there is now stricter validation of the values of the ``issuer`` option (https://github.com/ansible-collections/community.crypto/pull/316)." diff --git a/plugins/module_utils/crypto/support.py b/plugins/module_utils/crypto/support.py index 414d3528..61d8d76d 100644 --- a/plugins/module_utils/crypto/support.py +++ b/plugins/module_utils/crypto/support.py @@ -253,9 +253,9 @@ def parse_name_field(input_dict, name_field_name=None): result.append((key, value)) else: if name_field_name: - raise ValueError( + raise TypeError( 'Value for {key} in {name} must be either a string or a list of strings'.format(key=key, name=name_field_name)) - raise ValueError('Value for {key} must be either a string or a list of strings'.format(key=key)) + raise TypeError('Value for {key} must be either a string or a list of strings'.format(key=key)) return result @@ -270,7 +270,7 @@ def parse_ordered_name_field(input_list, name_field_name): name=name_field_name, index=index + 1)) try: result.extend(parse_name_field(entry, name_field_name=name_field_name)) - except ValueError as exc: + except (TypeError, ValueError) as exc: raise ValueError( 'Error while processing entry #{index} in {name}: {error}'.format( name=name_field_name, index=index + 1, error=exc))