Skip to content

Omit the default plugin install selection from SDK requests - #1802

Merged
SawyerHood merged 3 commits into
mainfrom
bb/draft-pr-for-1662-cli-server-payload-drift-bb-pl-thr_ebtwy6ngpm
Aug 18, 2026
Merged

SawyerHood merged 3 commits into
mainfrom
bb/draft-pr-for-1662-cli-server-payload-drift-bb-pl-thr_ebtwy6ngpm

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Aug 18, 2026 •

Copy link
Copy Markdown
Collaborator

What was wrong

bb plugin install <path> builds its request through @bb/sdk. Since fc34548 (#1579, first shipped in bb-app 0.38.0) the SDK sent selection: { kind: "root" } on every install, even a plain root install where the server defaults the selection to root anyway. Servers released before that commit (bb-app <= 0.37.x) validate POST /api/v1/plugins/install with a strict { source }-only schema, so a >= 0.38.0 CLI against a <= 0.37.x server got HTTP 422: expected { "source": string }, while a hand-written curl -d '{"source": ...}' succeeded against the same server. The SDK filled a server-owned default on the client, which broke forward compatibility with strict schemas.

What changed

  • packages/sdk/src/areas/plugins.ts: pluginSourceSelection returns undefined for a root install. The SDK sends selection only when the caller sets --plugin or --subdirectory. The body still passes through pluginInstallSourceRequestSchema.parse for validation, but the SDK sends the caller-set keys, not the parsed output with the filled default.
  • packages/server-contract/src/api/plugins.ts: installedPluginSchema.publisherLabel defaults to null when a response omits it. A 0.37.x server installs the plugin and then answers with the 0.37.x plugin shape, which has no publisherLabel; the SDK used to throw on that response after the server had already applied the change. Same pattern as the existing capabilities default in that schema.
  • packages/sdk/test/plugin-install-body.test.ts: new repro test. It mimics a 0.37.x server (strict { source } request, 0.37.x plugin response) and requires the root install round trip to resolve, and asserts the request body. It fails before the change and passes after.
  • Body assertions updated in packages/sdk/test/sdk.test.ts, apps/cli/src/__tests__/command-output/plugin-catalog.test.ts, apps/app/src/hooks/queries/plugin-catalog-queries.test.ts, and apps/app/src/components/plugin/management/AddPluginDialog.test.tsx.

No route or request fields change; the only contract change is the response-side publisherLabel default. No server/daemon wire change, so HOST_DAEMON_PROTOCOL_VERSION stays the same. No CLI flags change.

Verification

  • Repro test before the fix: pnpm exec turbo run test --filter=@bb/sdk -- plugin-install-body -> 1 failed (a plain root install sends only { source }), 1 passed.
  • Repro test with only the request fix (no publisherLabel default): 1 failed (Invalid input: expected string, received undefined at plugin.publisherLabel).
  • After both fixes: pnpm exec turbo run typecheck test --filter=@bb/server-contract --filter=@bb/sdk --filter=@bb/cli --force -> typecheck clean, server-contract 57/57, sdk 93/93, cli 450/450 passed. @bb/server and @bb/app typecheck clean.
  • pnpm exec turbo run typecheck test --filter=@bb/cli --force -> typecheck clean, 49 files / 450 tests passed.
  • pnpm exec turbo run typecheck --filter=@bb/app --force -> clean; pnpm exec turbo run test --filter=@bb/app -- plugin-catalog-queries AddPluginDialog -> 2 files / 20 tests passed.

Scope

This PR fixes the reported failure: a >= 0.38.0 CLI can now install a plugin on a <= 0.37.x server, and the response parses. The report also proposes a general CLI-side version-skew warning (compare GET /api/v1/system/version with the CLI version). That is a separate change and is not in this PR; other newer-CLI-vs-older-server paths are not covered here.

Fixes #1662

Report: https://get-bb.github.io/reports/issues/1662.html

AGENT GENERATED: by Claude Opus 5

@bb-slop-cop

bb-slop-cop Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

🚨 slopcop/review — I am SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior.

});
// The response is a stub, so response parsing may throw; only the request
// body matters here.
await sdk.plugins.install(args).catch(() => undefined);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 slopcop/review — This catch hides a real legacy response failure after a successful install.

A version 0.37 server omits publisherLabel, but the current installed-plugin schema requires it.
The SDK then throws after the server installs the plugin.
The CLI reports failure after a successful change.

Return a realistic version 0.37 response and require this call to resolve.
Default the missing direct-install label to null, or add version negotiation before the POST.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the follow-up commit: installedPluginSchema.publisherLabel now defaults to null when a response omits it (same pattern as the capabilities default), and the test returns a full 0.37.x plugin response and requires sdk.plugins.install to resolve instead of catching the error. The test fails without the default (expected string, received undefined at plugin.publisherLabel) and passes with it. PR body updated to say what the fix covers.

@bb-slop-cop bb-slop-cop Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 SLOP COP 🚨 · review

Plain-English summary

This PR removes a default plug-in choice from install requests.
Older servers reject that extra choice.
Explicit subdirectory and collection choices still go to the server.

Finding

High: The compatibility test hides a response error after the server completes the install.
The current SDK requires publisherLabel, but version 0.37 servers do not return it.
Thus, the CLI can report failure after a successful install.
The PR body notes this gap, but Fixes #1662 still overstates the result.

See the inline comment.

Review results

  • Security: I found no new security issue.
  • Performance: I found no new loop, I/O, cache, or retained-state cost.
  • Architecture: I found no duplicate selection helper or useful shared refactor.
  • Tests: The SDK type check and all 92 SDK tests passed.
  • Tests: All 17 focused CLI tests and all 20 focused app tests passed.
  • Browser test: The local app did not start within the review window.
  • Browser test: Its plug-in SDK declaration build did not finish, so I stopped the local process.

SawyerHood and others added 2 commits August 18, 2026 19:29
The SDK sent selection: { kind: "root" } on every plugin install, even
when the caller asked for a plain root install. Servers older than
bb-app 0.38.0 validate POST /api/v1/plugins/install with a strict
{ source }-only schema, so a newer CLI got HTTP 422 'expected { "source":
string }' while a hand-written curl succeeded. The server already
defaults selection to root, so the SDK now sends selection only when the
caller sets --plugin or --subdirectory.

Fixes #1662

Co-Authored-By: Claude <[email protected]>
A bb-app 0.37.x server installs the plugin, then answers with the
0.37.x installed-plugin shape, which has no publisherLabel. The SDK
required that field and threw after the server had applied the change,
so the CLI reported a failure after a successful install. The contract
now defaults a missing publisherLabel to null, and the #1662 repro test
requires the legacy round trip to resolve instead of swallowing the
error.

Co-Authored-By: Claude <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/draft-pr-for-1662-cli-server-payload-drift-bb-pl-thr_ebtwy6ngpm branch from c352606 to a06ff85 Compare August 18, 2026 19:31
@SawyerHood
SawyerHood merged commit 274ec31 into main Aug 18, 2026
10 checks passed
@SawyerHood
SawyerHood deleted the bb/draft-pr-for-1662-cli-server-payload-drift-bb-pl-thr_ebtwy6ngpm branch August 18, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI/server payload drift: bb plugin install <path> gets HTTP 422 'expected {source}' while direct POST /api/v1/plugins/install succeeds

1 participant