fix(plugins): let an operator disable a plugin whose code is missing - #1037
Merged
Conversation
A plugin can be installed — registry entry, config, storage, and the enabledByOperator decision that boot reads — while its package directory is gone: an interrupted update, or a directory that was never on the data volume. disable() threw NotFound in that state, because the loader had nothing to tear down, so the operator had no route at all to withdraw the standing instruction to enable it on every boot. Reinstalling the code brought the plugin back up. disable expresses intent rather than performing a runtime operation, and the registry is where intent lives. It now clears the decision against the registry when the plugin is not loaded, and 404s only for an id with no entry at all — which is what a 404 should mean. This is the same reasoning the not-ENABLED branch below it already applies to a plugin sitting in ERROR.
The route's 404 was operator-visible behaviour and the fix changes what an operator can do, so it belongs in the release notes rather than only in the PR.
rmyndharis
force-pushed
the
fix/disable-unloaded-plugin
branch
from
August 1, 2026 08:16
a5649e3 to
d1956e4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A plugin can exist in the registry — entry, config, per-plugin storage, and the
enabledByOperatordecision that boot reads — while its package directory is gone. An interrupted update leaves that state, and so does a directory that was never on the data volume in the first place.In that state
POST /plugins/:id/disablereturned 404:The branch immediately below already recognises that clearing the boot decision matters even when there is nothing running. The
!pluginguard returns before reaching it, so the operator had no route at all to withdraw a standing instruction to enable the plugin on every boot. Reinstalling the code later brought it straight back up. The only workarounds were uninstalling — which also destroys the plugin's stored data — or hand-editingregistry.json.Observed on a 0.12.1 host: two registry entries left at
enabledByOperator: trueafter their code was lost, both answering 404 to every disable attempt.Change
disableexpresses intent; it is not a runtime operation, and the registry is where intent lives. When the plugin is not loaded but a registry entry exists, the decision is now cleared against the registry and the call succeeds. A 404 is reserved for an id with no entry at all — which is what a 404 should mean.PluginLoaderService.getRegistryEntryis added to make that distinction available; it reads through to the storage service's existing accessor.Nothing else changes: there is no runtime to tear down in this state, so no lifecycle hook is skipped and no worker is left behind.
Tests
Two cases in
plugins.service.spec.ts, using the existing real-loader-and-disk harness: a plugin is installed and marked enabled-by-operator, its directory is removed, and a fresh loader and service are built over the same registry — reproducing a restart that re-reads the registry and loads nothing. Disabling it then succeeds and clears the flag. The second case asserts an unknown id still throws NotFound.Reverting the change fails the first and leaves the other 46 green.
src/modules/plugins+src/core/plugins: 443 passed.tsc --noEmitand eslint clean.