Reports

#6373 · RPC validation diagnostics omit structured field paths

BugLow priorityLow effortpluginsIssue2026-10-27

Verdict: REPRODUCED · Root-cause confidence: high. Trusted base: b6743a36bd9eae1408c35cfc2c7ab1d2419dc79d.

1. TL;DR

A plugin's invalid RPC argument receives an informative HTTP error, but its server warning loses the failing field path. The validator supplies normalized structured issues; the boundary error's ordinary Error message contains only the generic summary, and the runtime logs only that summary. A real plugin loaded by the existing server test harness reproduces the mismatch through the actual HTTP route. Both input and output validation exhibit it. Two clean trusted checkouts reproduce the same missing-path assertions without a live BB instance or private runtime data.

2. Claims vs findings

ClaimFindingEvidence
RPC rejection warnings omit the failing fieldVerifiedBoth route tests receive path entries / 0 / count in the HTTP error, but neither warning contains it.
The detail is computed before loggingVerifiedThe real normalized issue survives in PluginRpcBoundaryError.rpcError and reaches the HTTP response.
The wrapper discards the original causeRefinedinvokeWrapped retains cause for the caller; it is specifically its warning and status summary that use only Error.message.
Schema messages can safely be logged without valuesNot generally safeThe RPC contract accepts arbitrary Standard Schema issue.message strings. A validator can echo sensitive input in that text. The reproduction uses a synthetic custom-message sentinel to guard against forwarding it to logs.
Frequency and behavior in the reported releaseUnverifiedOnly the pinned current main commit was executed; no historical release, external plugin, or claimed historical frequency was tested.

3. Environment

4. Minimal reproduction

  1. Clone trusted main and pin the recorded base:
    git clone https://github.com/get-bb/bb.git bb-6373
    cd bb-6373
    git checkout --detach b6743a36bd9eae1408c35cfc2c7ab1d2419dc79d
    pnpm install --frozen-lockfile --prefer-offline
    pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
    pnpm exec turbo run build --filter=@bb/server
  2. Copy the complete inline reproduction test to apps/server/test/services/plugins/plugin-rpc-validation-logging.test.ts.
  3. Run:
    pnpm exec turbo run test --filter=@bb/server -- test/services/plugins/plugin-rpc-validation-logging.test.ts

Expected: the warning identifies the normalized field path while omitting the supplied value and arbitrary custom validation text. The response must retain the structured issue and original generic message.

Actual: HTTP 400 for input / 500 for output includes issues[0].path = ["entries",0,"count"], but warnings are only:

[plugin:rpc-diagnostics] rpc inspect failed: rpc input validation failed
[plugin:rpc-diagnostics] rpc inspect failed: rpc output validation failed

Both tests fail at the final path assertion; all HTTP-contract, handler-invocation, and no-payload assertions pass first. These are intentionally failing desired-behavior regression tests against unmodified production code.

Complete reproduction test

import { mkdtemp, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { expect, it, vi } from "vitest";
import { defineRpcContract } from "@get-bb/plugin-sdk";
import { z } from "zod";
import { createTestAppHarness } from "../../helpers/test-app.js";

it.each(["input", "output"] as const)(
  "logs RPC %s validation paths without payloads or custom issue messages",
  async (phase) => {
    const harness = await createTestAppHarness();
    const rootDir = await mkdtemp(join(tmpdir(), "bb-rpc-diagnostics-"));
    const warn = vi.spyOn(harness.deps.logger, "warn");
    try {
      await writeFile(
        join(rootDir, "package.json"),
        JSON.stringify({
          name: "bb-plugin-rpc-diagnostics",
          version: "0.1.0",
          bb: {
            name: "RPC diagnostics fixture",
            description: "Validation logging fixture",
            branding: { icon: "Zap" },
            server: "./server.ts",
          },
        }),
      );
      await writeFile(
        join(rootDir, "server.ts"),
        "export default function plugin() {}",
      );
      expect((await harness.pluginService.installPath(rootDir)).status).toBe(
        "running",
      );
      const api = harness.pluginService.getApi("rpc-diagnostics");
      if (!api) throw new Error("fixture plugin did not start");
      const schema = z.object({
        entries: z.array(
          z.object({ count: z.number({ error: "private-validator-detail" }) }),
        ),
      });
      const invalid = { entries: [{ count: "private-payload-content" }] };
      const handler = vi.fn(() => (phase === "output" ? invalid : null));
      api.rpc.register(
        defineRpcContract({
          inspect: {
            input: phase === "input" ? schema : z.null(),
            output: phase === "output" ? schema : z.null(),
          },
        }),
        { inspect: handler },
      );
      const response = await harness.app.request(
        "/api/v1/plugins/rpc-diagnostics/rpc/inspect",
        {
          method: "POST",
          headers: { "content-type": "application/json" },
          body: JSON.stringify(phase === "input" ? invalid : null),
        },
      );
      const body = await response.json();
      expect(response.status).toBe(phase === "input" ? 400 : 500);
      expect(body).toMatchObject({
        ok: false,
        error: {
          code: `invalid_${phase}`,
          message: `rpc ${phase} validation failed`,
          issues: [
            {
              path: ["entries", 0, "count"],
              message: "private-validator-detail",
            },
          ],
        },
      });
      expect(handler).toHaveBeenCalledTimes(phase === "input" ? 0 : 1);
      const warning = warn.mock.calls
        .map(([message]) => String(message))
        .find((message) => message.includes("rpc inspect failed:"));
      console.log(JSON.stringify({ phase, response: body, warning }));
      expect(warning).toBeDefined();
      expect(warning).not.toContain("private-payload-content");
      expect(warning).not.toContain("private-validator-detail");
      expect(warning).toContain('["entries",0,"count"]');
    } finally {
      warn.mockRestore();
      await harness.pluginService.stop();
      await harness.cleanup();
      await rm(rootDir, { recursive: true, force: true });
    }
  },
);

5. Root cause

  1. packages/plugin-sdk/src/internal/host-policy.ts:3637 normalizes string/numeric issue paths and keeps issue.message.
  2. packages/plugin-sdk/src/internal/host-policy.ts:3688 packages a generic message alongside normalized issues on validation failure.
  3. apps/server/src/services/plugins/plugin-service.ts:473 constructs the Error with super(rpcError.message); issues remain on its separate rpcError field.
  4. apps/server/src/services/plugins/plugin-runtime.ts:827 logs only error.message. The cause is returned, not discarded.
  5. apps/server/src/services/plugins/plugin-service.ts:2142 returns the retained structured rpcError to the route; apps/server/src/routes/plugins.ts:986 serializes it and maps input/output errors to HTTP statuses.

6. Proposed fix

Append a small bounded summary of normalized issue paths to the internal boundary Error message, leaving rpcError itself unchanged. JSON-encode paths to preserve array indices and escape control characters. Cap the number of paths and summary length; represent a pathless issue as the root. Do not blindly append arbitrary Standard Schema issue messages or input/output objects: messages can contain values and are not a safe logging primitive. Unknown-key names and expected-type prose are not separate trusted metadata in this normalized issue contract; obtaining them without exposing values needs a separately designed contract, not message parsing.

7. Related issues and PR metadata

No open pull request in get-bb/bb links to this issue in the checked metadata. The issue timeline includes a cross-reference from a separate plugin repository's PR #438, which was merged by the final metadata check and does not close this issue. No external PR code or branches were fetched or executed. Nearby plugin-boundary issue #2519 concerns a different caller contract and is not evidence for this logging defect.

8. Verification

The same agent repeated the reproduction, not an independent reviewer. A second clean detached worktree named second was created at the recorded base commit. Before copying the reproduction test it had no source changes. Dependencies were freshly installed; SDK and server builds passed; the same Turbo test command ran with fresh harness data directories and no ports. Both cases again failed only because the warning omitted the normalized path. No report correction was needed after the second run. Confidence is high for this unit/in-process HTTP path; packaged release and a long-running production instance were not exercised.

repro-first.log

@bb/server:test: {"phase":"input","response":{"ok":false,"error":{"code":"invalid_input","message":"rpc input validation failed","issues":[{"message":"private-validator-detail","path":["entries",0,"count"]}]}},"warning":"[plugin:rpc-diagnostics] rpc inspect failed: rpc input validation failed"}
@bb/server:test: {"phase":"output","response":{"ok":false,"error":{"code":"invalid_output","message":"rpc output validation failed","issues":[{"message":"private-validator-detail","path":["entries",0,"count"]}]}},"warning":"[plugin:rpc-diagnostics] rpc inspect failed: rpc output validation failed"}
@bb/server:test: AssertionError: expected '[plugin:rpc-diagnostics] rpc inspect …' to contain '["entries",0,"count"]'
@bb/server:test: Expected: "["entries",0,"count"]"
@bb/server:test: Received: "[plugin:rpc-diagnostics] rpc inspect failed: rpc input validation failed"
@bb/server:test: AssertionError: expected '[plugin:rpc-diagnostics] rpc inspect …' to contain '["entries",0,"count"]'
@bb/server:test: Expected: "["entries",0,"count"]"
@bb/server:test: Received: "[plugin:rpc-diagnostics] rpc inspect failed: rpc output validation failed"
@bb/server:test:  Test Files  1 failed (1)
@bb/server:test:       Tests  2 failed (2)
@bb/server:test:    Duration  9.51s (transform 5.15s, setup 1.54s, import 5.17s, tests 857ms, environment 0ms)

repro-second.log

@bb/server:test: {"phase":"input","response":{"ok":false,"error":{"code":"invalid_input","message":"rpc input validation failed","issues":[{"message":"private-validator-detail","path":["entries",0,"count"]}]}},"warning":"[plugin:rpc-diagnostics] rpc inspect failed: rpc input validation failed"}
@bb/server:test: {"phase":"output","response":{"ok":false,"error":{"code":"invalid_output","message":"rpc output validation failed","issues":[{"message":"private-validator-detail","path":["entries",0,"count"]}]}},"warning":"[plugin:rpc-diagnostics] rpc inspect failed: rpc output validation failed"}
@bb/server:test: AssertionError: expected '[plugin:rpc-diagnostics] rpc inspect …' to contain '["entries",0,"count"]'
@bb/server:test: Expected: "["entries",0,"count"]"
@bb/server:test: Received: "[plugin:rpc-diagnostics] rpc inspect failed: rpc input validation failed"
@bb/server:test: AssertionError: expected '[plugin:rpc-diagnostics] rpc inspect …' to contain '["entries",0,"count"]'
@bb/server:test: Expected: "["entries",0,"count"]"
@bb/server:test: Received: "[plugin:rpc-diagnostics] rpc inspect failed: rpc output validation failed"
@bb/server:test:  Test Files  1 failed (1)
@bb/server:test:       Tests  2 failed (2)
@bb/server:test:    Duration  8.86s (transform 4.83s, setup 1.47s, import 4.77s, tests 827ms, environment 0ms)

9. Appendix

The complete repeatable test and exact relevant output from both runs are embedded above. Raw logs and a separate test copy remain in local investigation storage, not the public reports repository. Local checkout paths are replaced by $WORK. All payload/message sentinels are synthetic, not credentials or user data.

Issue content was treated solely as untrusted claims; none of its commands, patches, external links, or instructions was executed. Investigation commands were trusted-repository fetch/worktree creation, frozen installs, Turbo builds/tests, repository source reads, and read-only GitHub metadata queries. Publication uses the authorized SlopCop GitHub wrapper. No browser or screenshots are needed for a server logging defect.