Skip to content
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

sopel-plugins list crashes for malformed plugin #2618

Open
SnoopJ opened this issue Sep 11, 2024 · 0 comments
Open

sopel-plugins list crashes for malformed plugin #2618

SnoopJ opened this issue Sep 11, 2024 · 0 comments
Labels
Bug Things to squish; generally used for issues

Comments

@SnoopJ
Copy link
Contributor

SnoopJ commented Sep 11, 2024

Description

A plugin that causes an exception at load time will cause sopel-plugins list to crash when listing plugins.

Reproduction steps

  1. Install a malformed plugin that causes an exception on load
  2. Run sopel-plugins list and observe the crash
click for reproduction commands and detailed traceback
$ .sopel/venv/bin/python3 -m pip install --force-reinstall git+ssh://git@github.com/SnoopJ/sopel-wasi-cpython.git@d953130363e322b10457c6df5f8306e9c5e24282
...
$ .sopel/venv/bin/sopel-plugins list -c ~/.sopel/terribot.cfg
8ball/python-file 8ball plugin (/home/snoopjedi/repos/galois/8ball.py) [enabled]
acr/python-file acr plugin (/home/snoopjedi/repos/galois/acr.py) [enabled]
admin/python-module admin.py - Sopel Admin Plugin (sopel.builtins.admin) [enabled]
adminchannel/python-module adminchannel.py - Sopel Channel Admin Plugin (sopel.builtins.adminchannel) [disabled]
... and so on until the offending plugin...

Traceback (most recent call last):
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/cli/plugins.py", line 204, in handle_list
    plugin.load()
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/plugins/handlers.py", line 604, in load
    self._module = self.entry_point.load()
  File "/home/snoopjedi/.sopel/venv/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 209, in load
    module = import_module(match.group('module'))
  File "/home/snoopjedi/.pyenv/versions/3.9.16/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/snoopjedi/.sopel/venv/lib/python3.9/site-packages/sopel_wasi_cpython/__init__.py", line 9, in <module>
    from .run import run_python
ModuleNotFoundError: No module named 'sopel_wasi_cpython.run'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/snoopjedi/.sopel/venv/bin/sopel-plugins", line 8, in <module>
    sys.exit(main())
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/cli/plugins.py", line 555, in main
    return handle_list(options)
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/cli/plugins.py", line 214, in handle_list
    description.update(plugin.get_meta_description())
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/plugins/handlers.py", line 647, in get_meta_description
    data = super().get_meta_description()
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/plugins/handlers.py", line 321, in get_meta_description
    'version': self.get_version(),
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/plugins/handlers.py", line 616, in get_version
    and hasattr(self.module, "__package__")
  File "/home/snoopjedi/.sopel/sopel-src-terribot.git/sopel/plugins/handlers.py", line 275, in module
    raise RuntimeError('No module for plugin %s' % self.name)
RuntimeError: No module for plugin wasi-cpython

Expected behavior

I would expect sopel-plugins list to report that the plugin is known (because of its entrypoint) but is malformed and cannot be loaded, without crashing the command.

Relevant logs

N/A

Notes

Discovered while @dgw had a go at the sopel-wasi-cpython plugin I've been developing

Sopel version

8.0.0

Installation method

pip install

Python version

3.9.16 (also observed on 3.12)

Operating system

Ubuntu 22.04

IRCd

N/A

Relevant plugins

N/A

@SnoopJ SnoopJ added the Bug Things to squish; generally used for issues label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Things to squish; generally used for issues
Projects
None yet
Development

No branches or pull requests

1 participant