fix(plugin): return not found after removal (#2483)

Co-authored-by: Hyu <chenhyu@proton.me>
This commit is contained in:
RockChinQ
2026-08-31 13:40:03 +08:00
committed by GitHub
parent e69a80f5e9
commit 1b7ae791b3
2 changed files with 20 additions and 2 deletions
+7 -2
View File
@@ -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)
@@ -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."""