Skip to content
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
2 changes: 2 additions & 0 deletions src/scope/core/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .hookspecs import hookimpl
from .manager import (
FailedPluginInfo,
PluginBundledError,
PluginDependencyError,
PluginInstallError,
PluginInUseError,
Expand Down Expand Up @@ -32,4 +33,5 @@
"PluginNameCollisionError",
"PluginDependencyError",
"PluginInstallError",
"PluginBundledError",
]
8 changes: 7 additions & 1 deletion src/scope/core/plugins/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ class PluginInstallError(Exception):
pass


class PluginBundledError(PluginInstallError):
"""Attempted to uninstall a bundled (built-in) plugin."""

pass


@dataclass(frozen=True)
class FailedPluginInfo:
"""Information about a plugin entry point that failed to load."""
Expand Down Expand Up @@ -1360,7 +1366,7 @@ def _uninstall_plugin_sync(

# Prevent uninstalling bundled plugins
if plugin_info.get("bundled"):
raise PluginInstallError(
raise PluginBundledError(
f"Plugin '{name}' is bundled and cannot be uninstalled"
)

Expand Down
7 changes: 7 additions & 0 deletions src/scope/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2957,6 +2957,7 @@ async def uninstall_plugin(
cloud-hosted scope backend.
"""
from scope.core.plugins import (
PluginBundledError,
PluginInstallError,
PluginNotFoundError,
get_plugin_manager,
Expand Down Expand Up @@ -2991,6 +2992,12 @@ async def uninstall_plugin(
status_code=404,
detail=f"Plugin '{name}' not found",
) from e
except PluginBundledError as e:
logger.warning(f"Plugin uninstall rejected (bundled plugin): {name} - {e}")
raise HTTPException(
status_code=400,
detail=str(e),
) from e
except PluginInstallError as e:
logger.error(f"Plugin uninstall failed: {name} - {e}")
raise HTTPException(
Expand Down
Loading