# Empty meta role file makes publish to galaxy fail

**URL:** <https://forum.ansible.com/t/empty-meta-role-file-makes-publish-to-galaxy-fail/4864>\
**Category:** Get Help\
**Tags:** role, collections, galaxy-ng\
**Created:** [April 10, 2024, 2:10pm UTC](https://forum.ansible.com/t/empty-meta-role-file-makes-publish-to-galaxy-fail/4864 "2024-04-10T14:10:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonyskapunk](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tonyskapunk/32/1435_2.png) [@tonyskapunk](https://forum.ansible.com/u/tonyskapunk)\
**Post date:** [April 10, 2024, 2:10pm UTC](https://forum.ansible.com/t/empty-meta-role-file-makes-publish-to-galaxy-fail/4864/1 "2024-04-10T14:10:49Z")

</div>

Using an empty `role/role_name/meta/main.yml` file in a collection makes galaxy to fail importing the collection when publishing

This is an example of a failed task importing the collection to be published:

[https://galaxy.ansible.com/api/v3/plugin/ansible/imports/collections/018e5752-8972-7202-b02d-c7798f4e3a0e/](https://galaxy.ansible.com/api/v3/plugin/ansible/imports/collections/018e5752-8972-7202-b02d-c7798f4e3a0e/)

The error is not quite clear but is complaining on meta fields of a role.

```JSON
    "error": {
        "traceback": " File \"/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py\", line 66, in _execute_task\n result = func(*args, **kwargs)\n ^^^^^^^^^^^^^^^^^^^^^\n File \"/app/galaxy_ng/app/tasks/publishing.py\", line 115, in import_and_auto_approve\n repo = _upload_collection(**kwargs)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/app/galaxy_ng/app/tasks/publishing.py\", line 65, in _upload_collection\n general_create(*general_args, **kwargs)\n File \"/venv/lib64/python3.11/site-packages/pulpcore/app/tasks/base.py\", line 37, in general_create\n serializer.is_valid(raise_exception=True)\n File \"/venv/lib64/python3.11/site-packages/rest_framework/serializers.py\", line 227, in is_valid\n self._validated_data = self.run_validation(self.initial_data)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/rest_framework/serializers.py\", line 429, in run_validation\n value = self.validate(value)\n ^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/pulp_ansible/app/serializers.py\", line 484, in validate\n return super().validate(data)\n ^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/pulpcore/plugin/serializers/content.py\", line 123, in validate\n data = self.deferred_validate(data)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/pulp_ansible/app/serializers.py\", line 494, in deferred_validate\n collection_info = process_collection_artifact(\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/pulp_ansible/app/tasks/upload.py\", line 37, in process_collection_artifact\n importer_result = import_collection(\n ^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/galaxy_importer/collection.py\", line 78, in import_collection\n return _import_collection(file, filename, file_url, logger, cfg)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/galaxy_importer/collection.py\", line 135, in _import_collection\n data = CollectionLoader(extract_dir, filename, cfg=cfg, logger=logger).load()\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/collection.py\", line 100, in load\n self.content_objs = list(self._load_contents())\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/collection.py\", line 378, in _load_contents\n content_obj = loader.load()\n ^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/content.py\", line 180, in load\n description = self._get_metadata_description()\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/content.py\", line 220, in _get_metadata_description\n description = role_metadata[\"galaxy_info\"][\"description\"]\n ~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^\n",
        "description": "'NoneType' object is not subscriptable"
    },

```

Later, it was found that empty meta causes it to fail, removing it allows the import of collection to complete and be published as in this test:

[https://galaxy.ansible.com/api/v3/plugin/ansible/imports/collections/018e632a-b646-7e94-8d07-ba2da3d7369b/](https://galaxy.ansible.com/api/v3/plugin/ansible/imports/collections/018e632a-b646-7e94-8d07-ba2da3d7369b/)

Is there any documentation available on the requirements of meta files for a role?

Thanks!

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [April 10, 2024, 2:48pm UTC](https://forum.ansible.com/t/empty-meta-role-file-makes-publish-to-galaxy-fail/4864/2 "2024-04-10T14:48:38Z")

</div>

According to [this page](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#sharing-roles-ansible-galaxy):

> the Galaxy Roles document… explains the required metadata your role needs for use in Galaxy [https://galaxy.ansible.com/docs/contributing/creating\_role.html](https://galaxy.ansible.com/docs/contributing/creating_role.html).

However that now redirects to `https://galaxy.ansible.com/ui/` but [the Internet Archive has a copy](https://web.archive.org/web/20230524210925/https://galaxy.ansible.com/docs/contributing/creating_role.html) and _“the default metadata file created by the `init` command”_:

```yaml
galaxy_info:
  role_name: foo
  author: your name
  description: your description
  company: your company (optional)

  # If the issue tracker for your role is not on github, uncomment the
  # next line and provide a value
  # issue_tracker_url: http://example.com/issue/tracker

  # Some suggested licenses:
  # - BSD (default)
  # - MIT
  # - GPLv2
  # - GPLv3
  # - Apache
  # - CC-BY
  license: license (GPLv2, CC-BY, etc)

  min_ansible_version: 1.2

  # If this a Container Enabled role, provide the minimum Ansible Container version.
  # min_ansible_container_version:

  # Optionally specify the branch Galaxy will use when accessing the GitHub
  # repo for this role. During role install, if no tags are available,
  # Galaxy will use this branch. During import Galaxy will access files on
  # this branch. If Travis integration is configured, only notifications for this
  # branch will be accepted. Otherwise, in all cases, the repo's default branch
  # (usually master) will be used.
  #github_branch:

  #
  # platforms is a list of platforms, and each platform has a name and a list of versions.
  #
  # platforms:
  # - name: Fedora
  # versions:
  # - all
  # - 25
  # - name: SomePlatform
  # versions:
  # - all
  # - 1.0
  # - 7
  # - 99.99

  galaxy_tags: []
    # List tags for your role here, one per line. A tag is a keyword that describes
    # and categorizes the role. Users find roles by searching for tags. Be sure to
    # remove the '[]' above, if you add tags to this list.
    #
    # NOTE: A tag is limited to a single word comprised of alphanumeric characters.
    # Maximum 20 tags per role.

dependencies: []
  # List your role dependencies here, one per line. Be sure to remove the '[]' above,
  # if you add dependencies to this list.

```

---

<div class="post-metadata">

**Author:** ![tonyskapunk](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tonyskapunk/32/1435_2.png) [@tonyskapunk](https://forum.ansible.com/u/tonyskapunk)\
**Post date:** [April 10, 2024, 3:48pm UTC](https://forum.ansible.com/t/empty-meta-role-file-makes-publish-to-galaxy-fail/4864/3 "2024-04-10T15:48:49Z")

</div>

Thanks for the info @chris it is quite useful for the parameters used in there.

While reading the [Roles — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#using-role-dependencies) it seems like the parameters are optional 🤔

> Role dependencies are stored in the `meta/main.yml` file within the role directory. This file **should** contain a list of roles and parameters to insert before the specified role.

I wonder if it should mention to not include empty files to avoid the problem we experienced when attempting to publish in galaxy. It took us a good amount of time to figure out the problem was an empty file. Or, if it should be reported as a bug in the import process of galaxy.
