AcademySoftwareFoundation / rez

An integrated package configuration, build and deployment system for software
https://rez.readthedocs.io
Apache License 2.0
938 stars 332 forks source link

Error searching for plugins if there is an empty package folder in the repo #1618

Open mmdanggg2 opened 8 months ago

mmdanggg2 commented 8 months ago

Calling rez.package_search.get_plugins with a package that has has_plugins set to True will error out if there is a folder in a package repo without a valid package in it. Simplest way to replicate this is just make an empty folder in ~/packages and try to run get_plugins:

>>> package_search.get_plugins("nuke")
Searching [#############                   ] 46/106Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/rez/rez_package_cache/rez/2.112.0/c2ee/a/rez/package_search.py", line 154, in get_plugins
    if not plugin_pkg.plugin_for:
AttributeError: 'NoneType' object has no attribute 'plugin_for'

I actually came across this while in the middle of building a new package that took some time, so it had created the package folder with a version and .building file but there was not a valid package in there yet and started to get reports of our launcher breaking.

Fix may be as simple as adding a check for None here: https://github.com/AcademySoftwareFoundation/rez/blob/7e8617d05aaf9e0e16257f7801857feb6e8f1c5c/src/rez/package_search.py#L154-L156

    if not plugin_pkg or not plugin_pkg.plugin_for: