diff --git a/changelog/1219.bugfix.md b/changelog/1219.bugfix.md new file mode 100644 index 000000000..e53471204 --- /dev/null +++ b/changelog/1219.bugfix.md @@ -0,0 +1 @@ +The logger for rasa_sdk plugin will not throw traceback when no plugins are found since plugins are optional. It will be only available in debug mode, however the action server will continue to run. \ No newline at end of file diff --git a/rasa_sdk/plugin.py b/rasa_sdk/plugin.py index 217ddecb7..462abc552 100644 --- a/rasa_sdk/plugin.py +++ b/rasa_sdk/plugin.py @@ -27,7 +27,7 @@ def _discover_plugins(manager: pluggy.PluginManager) -> None: rasa_sdk_plugins.init_hooks(manager) except ModuleNotFoundError as e: - logger.info("No plugins found", exc_info=e) + logger.debug("No plugins found: %s", e) pass diff --git a/tests/test_plugin.py b/tests/test_plugin.py index ecd0d8564..c984f7e73 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -1,6 +1,7 @@ +import logging import warnings -from pytest import MonkeyPatch +from pytest import MonkeyPatch, LogCaptureFixture from pluggy import PluginManager from unittest.mock import MagicMock @@ -8,6 +9,16 @@ from rasa_sdk.plugin import plugin_manager +def test_plugins_not_found(caplog: LogCaptureFixture) -> None: + """Test that a debug message is logged when no plugins are found. + + This test must be run first because the plugin manager is cached. + """ + with caplog.at_level(logging.DEBUG): + plugin_manager() + assert "No plugins found: No module named 'rasa_sdk_plugins'" in caplog.text + + def test_plugin_manager() -> None: manager = plugin_manager() assert isinstance(manager, PluginManager)