Skip to content

Replacing a local plugin source destroys its settings silently: remove is the only supported path and it deletes plugin_settings #1766

Closed

Description

@pixexid

Summary

Replacing a local (path-source) plugin destroys all of its persisted settings, silently. The CLI offers no in-place replace for a local source, so the only supported path is bb plugin remove followed by install — and remove deletes the plugin's settings rows, schedules and secrets. Operators who reinstall a local plugin from a new checkout silently return to plugin defaults with no error, no warning and no log line.

We hit this in production use, not in a lab: tuned watchdog thresholds silently reverted to defaults mid-operation and invalidated a verification run. It was caught only because that run happened to read its settings back afterwards.

Mechanism

bb-app/server/dist/start-server.js

Call site, in the plugin-removal path (~311140):

if (removed && row) {
  forgetMutableRoot(row.rootDir);
  deletePluginSchedules(deps.db, id);
  deleteAllPluginSettings(deps.db, id);
  await rm11(pluginSecretsDir(deps.dataDir, id), { recursive: true, force: true });

Definition (~31757):

function deleteAllPluginSettings(db, pluginId) {
  db.delete(pluginSettings).where(eq(pluginSettings.pluginId, pluginId)).run();
}

So a remove drops settings, schedules and secrets together.

What we ruled out

We checked the two other explanations before filing, because they imply different bugs:

  • Not a reload problem. A same-source reload (bb plugin reload <id>) preserves settings. Verified by reading effective values before and after: unchanged.
  • Not key orphaning. plugin_settings is keyed by (plugin_id, key) with no source-path column, so a changed path under the same plugin id reads the same rows. Values are not stranded under an old key — they are deleted.

The blast radius is therefore bounded to remove/install replacement, not to every plugin reload.

Why this is worse than it looks

The data loss is invisible at exactly the moment an operator is least likely to check. Reinstalling from a new checkout looks like a deployment, not a reset, so there is no prompt to re-verify configuration. The plugin comes back up healthy, reporting ok, running on defaults the operator did not choose and does not know they are on.

In our case the affected settings governed a watchdog's alerting thresholds. It reverted from a 1-minute floor to a 1-hour floor and from a 3-minute stale window to a 24-hour one, while continuing to report healthy. A monitoring component that silently reverts to defaults is one nobody can trust to be running the configuration they set.

Suggested directions

Any one of these would close it; we have no stake in which:

  1. An in-place replace for local sources, so remove is not the only route.
  2. Preserve plugin_settings across a remove/install of the same plugin id (or retain and offer restore).
  3. Failing either, make the loss loud: warn at remove time that settings/schedules/secrets will be destroyed, and require confirmation.

(3) alone would have saved us, and is the smallest.

Environment

bb 0.38, macOS. Local path-source plugin.

Activity

  1. pixexid commented on Aug 18, 2026

    @pixexid
    Author

    Doc-level corroboration: bb plugin remove --help states only — "Remove an installed plugin (git:/npm: managed files are deleted; local path sources are left alone)" — and no documentation mentions settings, schedules, or secrets in connection with remove. The "left alone" phrasing reads to a user as non-destructive for local-path plugins, while the remove path destroys plugin_settings rows, plugin schedules, and the plugin secrets directory. Found while verifying the filed citations against the bb 0.38.0 bundle and CLI help text.

  2. added theissue type on Aug 18, 2026
  3. added
    plugins
    on Aug 18, 2026
  4. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1766.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): Registration refuses a same-id path: install from a different directory (plugin-registration.ts assertInstallRegistrationAvailable) and update is a no-op for path rows, so the only route is remove+install; PluginService.remove() unconditionally deletes plugin_settings, plugin schedules and the secrets dir (plugin-service.ts ~L1681-1694) with no log/warning, and CLI help + the local-plugin UI dialog describe remove as non-destructive.
    • Proposed fix: Allow an in-place path->path replace for the same plugin id in apps/server/src/services/plugins/plugin-registration.ts (relax assertInstallRegistrationAvailable when existing.sourceKind==="path" && intent.kind==="path" && provenance is direct; dispose old instance, upsert row with new sourcePath/rootDir, forgetMutableRoot(old), loadOne) -- settings/secrets/schedules are keyed by plugin id only so they survive; optionally gate behind bb plugin install --replace / POST /plugins {replace:true}. Independently make remove honest and loud: update CLI description (apps/cli/src/commands/plugin.ts:18…
    • Caveats: Bundle line numbers cited in the issue (bb 0.38 start-server.js) were not checked against the release bundle; the TS source at HEAD matches the quoted code and the behaviour dates to the original plugin-system commit 66ddc60, so it is present in HEAD (not fixed). Repro test file was left uncommitted in the worktree at apps/server/test/services/plugins/issue-1766-local-replace-loses-settings.test…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  5. added
    confirmed-repro
    on Aug 18, 2026
  6. added a commit that references this issue on Aug 21, 2026
    dfdf9a9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproplugins

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions