errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.09k stars 608 forks source link

Fixes #1619 Improve error reporting for plugin activation #1620

Closed nzlosh closed 1 year ago

nzlosh commented 1 year ago

Part of the plugin activation process uses a list created from content on-disk and their dependencies self.get_plugins_activation_order(), however the list of plugins in self.plugins are only those that were successfully loaded during bootstrap.

A test to determine if the returned plugin is None has been added to log and skip activation of plugins that failed to be loaded for clearer error reporting.

This PR also includes a minor fix for duplicate log entries when calling warn_admins. An info and warning entry were created if a plugin fails to load, but with this patch, a single warning will be created, like the following log sample:

14:58:58 WARNING  errbot.plugin_manager     Skipping activation for plugin 'Error' because it is not loaded.  Check logs for errors while loading the plugin.
14:58:58 DEBUG    errbot.plugin_manager     Activate flow plugins ...
14:58:58 WARNING  errbot.core               Some plugins failed to start during bot startup:

Traceback (most recent call last):
  File "/opt/errbot/lib/python3.10/site-packages/errbot/plugin_manager.py", line 303, in _load_plugins_generic
    dest_dict[name] = self._plugin_instance_callback(name, clazz)
  File "/opt/errbot/lib/python3.10/site-packages/errbot/bootstrap.py", line 187, in <lambda>
    lambda name, clazz: clazz(bot, name),
TypeError: Example.__init__() takes 1 positional argument but 3 were given
sijis commented 1 year ago

@nzlosh I've fixed the current build issues, however, i cannot seem to get this tests to pass. Could you figure out why the build is failing on this PR?