diff --git a/changelogs/fragments/collection_error_fix.yml b/changelogs/fragments/collection_error_fix.yml new file mode 100644 index 00000000000..00f6c0876cb --- /dev/null +++ b/changelogs/fragments/collection_error_fix.yml @@ -0,0 +1,2 @@ +minor_changes: +- Provides additional information about collection namespace name restrictions (https://github.com/ansible/ansible/issues/65151). diff --git a/lib/ansible/galaxy/collection.py b/lib/ansible/galaxy/collection.py index b3e150fb0af..0569605a3de 100644 --- a/lib/ansible/galaxy/collection.py +++ b/lib/ansible/galaxy/collection.py @@ -454,7 +454,10 @@ def validate_collection_name(name): if AnsibleCollectionRef.is_valid_collection_name(collection): return name - raise AnsibleError("Invalid collection name '%s', name must be in the format .." % name) + raise AnsibleError("Invalid collection name '%s', " + "name must be in the format .. " + "Please make sure namespace and collection name contains " + "characters from [a-zA-Z0-9_] only." % name) @contextmanager diff --git a/lib/ansible/utils/collection_loader.py b/lib/ansible/utils/collection_loader.py index 81e3f4fac02..ec496524b5b 100644 --- a/lib/ansible/utils/collection_loader.py +++ b/lib/ansible/utils/collection_loader.py @@ -474,7 +474,7 @@ class AnsibleCollectionRef: @staticmethod def is_valid_collection_name(collection_name): """ - Validates if is string is a well-formed collection name (does not look up the collection itself) + Validates if the given string is a well-formed collection name (does not look up the collection itself) :param collection_name: candidate collection name to validate (a valid name is of the form 'ns.collname') :return: True if the collection name passed is well-formed, False otherwise """