From 1b7ae791b3dc396ac13900521812c4ee639c0b31 Mon Sep 17 00:00:00 2001 From: RockChinQ Date: Mon, 31 Aug 2026 13:40:03 +0800 Subject: [PATCH] fix(plugin): return not found after removal (#2483) Co-authored-by: Hyu --- src/langbot/pkg/plugin/connector.py | 9 +++++++-- tests/unit_tests/plugin/test_connector_methods.py | 13 +++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/langbot/pkg/plugin/connector.py b/src/langbot/pkg/plugin/connector.py index 03893cf4c..7df06aefe 100644 --- a/src/langbot/pkg/plugin/connector.py +++ b/src/langbot/pkg/plugin/connector.py @@ -1913,9 +1913,14 @@ class PluginRuntimeConnector(ManagedRuntimeConnector): return plugins - async def get_plugin_info(self, author: str, plugin_name: str) -> dict[str, Any]: + async def get_plugin_info(self, author: str, plugin_name: str) -> dict[str, Any] | None: runtime_handler = self._runtime_handler() - binding = await self._target_binding(author, plugin_name) + try: + binding = await self._target_binding(author, plugin_name) + except ValueError as exc: + if str(exc) == f'Plugin {author}/{plugin_name} is not installed in this Workspace': + return None + raise with runtime_handler.installation_scope(binding): return await runtime_handler.get_plugin_info(author, plugin_name) diff --git a/tests/unit_tests/plugin/test_connector_methods.py b/tests/unit_tests/plugin/test_connector_methods.py index 3fd099b5c..d2fb26f54 100644 --- a/tests/unit_tests/plugin/test_connector_methods.py +++ b/tests/unit_tests/plugin/test_connector_methods.py @@ -640,6 +640,19 @@ class TestGetPluginInfo: connector.handler.get_plugin_info.assert_called_once_with('author', 'plugin') assert result == {'manifest': {'metadata': {'name': 'plugin'}}} + @pytest.mark.asyncio + async def test_returns_none_when_plugin_is_not_installed(self): + connector = create_mock_connector() + configure_handler(connector, AsyncMock()) + connector._target_binding = AsyncMock( + side_effect=ValueError('Plugin author/plugin is not installed in this Workspace') + ) + + result = await connector.get_plugin_info('author', 'plugin') + + assert result is None + connector.handler.get_plugin_info.assert_not_awaited() + class TestSetPluginConfig: """Tests for set_plugin_config method."""