Skip to content

Add doc warning for risky plugin names (related to #1694) #1722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/plugindevelopment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.. warning::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning can be very useful for plugin developers.


Avoid naming your plugin directory or module lib, test, or utils. These names are common in Python or used internally by some backends (e.g., Slack). Using them may cause your plugin to fail to load due to module resolution conflicts. Prefer unique, descriptive names such as lib_tools or myplugin_utils.
6 changes: 5 additions & 1 deletion errbot/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ def _load_plugins_generic(
feedback: Dict[Path, str],
):
self._install_potential_package_dependencies(path, feedback)
plugfiles = path.glob("**/*." + extension)

plugfiles = []
for ext in ("plug", "plugin"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unfortunately would break the usage in

def _load_plugins(self) -> Dict[Path, str]:
feedback = {}
for path in self.plugin_places:
self._load_plugins_generic(
path,
"plug",
"errbot.plugins",
BotPlugin,
self.plugins,
self.plugin_infos,
feedback,
)
self._load_plugins_generic(
path,
"flow",
"errbot.flows",
BotFlow,
self.flows,
self.flow_infos,
feedback,
)
return feedback
, as the parameters being passed include plug and flow. This change, unfortunately does not address that and include a new one named plugin.

plugfiles.extend(path.glob(f"**/*.{ext}"))

for plugfile in plugfiles:
try:
plugin_info = PluginInfo.load(plugfile)
Expand Down
Loading