Repository navigation
Description
Summary
bb plugin enable <id> returns exit code 0 whenever the server knows the plugin, even if the load triggered by the enable fails and the plugin ends in status error. The failure is visible only as text in the human-readable output; --json reports ok: true as well. Scripts that chain on the exit code treat the plugin as enabled when it is not running.
Observed on bb 0.45.0 (npm bb-app); the code paths below are unchanged on main at 7fd6ee9.
Reproduction
-
Create a path plugin whose server factory throws:
export default definePlugin(() => { throw new Error("boom"); });
-
bb plugin install path:./boom-plugin(loads once, ends inerror), thenbb plugin disable boom-plugin. -
bb plugin enable boom-plugin; echo $?
Output (shape; statusDetail text depends on the thrown error):
[email protected] error (boom)
source: path:...
0
bb plugin enable boom-plugin --json prints {"ok":true,"plugin":{...,"enabled":true,"status":"error",...}} and exits 0 too.
A provider plugin whose provider id is already registered by another running plugin behaves the same way; the throwing factory is just the smallest reproduction.
Why
apps/server/src/routes/plugins.ts:756-761—POST /plugins/:id/enableanswers{ ok: true, plugin }as long assetEnabledreturns a row; the response does not look atplugin.status.apps/server/src/services/plugins/plugin-service.ts:1686-1718—setEnabledrunsloadOne(row)and returnslist().find(...), so a failed load is reported only throughstatus/statusDetailon the returned entry.apps/cli/src/commands/plugin.ts:1600-1621— the CLI callsexitWithErroronly when!result.ok || !result.plugin, thenprintPluginshows the status and the command exits 0.
The neighbouring commands already fail loudly:
bb plugin reloadreturns{ ok: false, error, plugins }with HTTP 422 when a plugin fails to load (plugin-service.ts:1767-1768,routes/plugins.ts:733-737), so the CLI exits 1.bb plugin safe-mode off"exits 1 if any fail to start" (apps/cli/src/commands/plugin.ts:1627).
Expected
When the enable results in a load error (enabled: true and status: "error"), bb plugin enable exits non-zero and --json reports ok: false with the statusDetail as error.
Note this is narrower than "anything other than running": a plugin held back by safe mode is reported as disabled with a safe-mode detail (apps/server/src/services/plugins/plugin-runtime.ts:1541-1547), and that is a legitimate successful enable (the row is enabled; it will start when safe mode is turned off). Only status === "error" should fail the command.
Suggested direction
Either have POST /plugins/:id/enable return { ok: false, error: statusDetail, plugin } (422, like reload) when the resulting status is error, or keep the route as is and let the CLI treat plugin.enabled && plugin.status === "error" as a failure. The first option also helps bb.sdk.plugins.enable() callers, who currently have to inspect status themselves.
Related, not duplicates: #2029 (closed; reload reported exit 0 while services were orphaned), #2286 (open; plugin health counters hide failures), #2382 (open; bb status exits 0 against a dead daemon).
Activity
bb-slop-cop commentedon Oct 5, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotClassification: Bug · Priority Medium · Effort Low ·
plugins,cli,confirmed-repro.Verdict: REPRODUCED, with high root-cause confidence, in two trusted-main checkouts at
f7f106dab.Report: https://get-bb.github.io/reports/issues/4940.html
Root cause: The enable endpoint returns a successful envelope whenever the installed plugin exists, even after its loader records an error. The CLI trusts that envelope and exits 0; the SDK also resolves with the failed plugin.
Evidence: The authored end-to-end regression fails in both checkouts: expected CLI exit 1, received 0 in human and JSON modes. Safe-mode-held enable succeeds as intended; four existing reload/safe-mode tests pass. The report embeds the complete reproduction test.
No PR: The root repair changes public enable API success/error semantics, which this rule excludes from its simple-fix scope.
ahmedhesham6 commentedon Oct 14, 2026
I'd like to work on this. I have a fix ready that takes the CLI-only route from the issue: when
enablereturns an enabled plugin withstatus: "error",bb plugin enablereportsok: falsewithstatusDetailaserrorand exits 1. A plugin that safe mode holds back still counts as a successful enable. It's about 15 lines inapps/cli/src/commands/plugin.ts, plus a regression test that fails before the fix.If you'd rather fix it in the server (return 422 from the enable route, like reload does), I can do that instead. I'm asking for contributor approval in Discord before I open the PR.
ahmedhesham6 commentedon Oct 15, 2026
I opened the fix as #5534. The contributor gate may close it until I have approval. If you approve me, I'll reopen it.
Exit 1 when bb plugin enable leaves the plugin in error (get-bb#5534)
Never report a failure as the user's answer to an agent (#7723)