← reports

#7022 · Unregistered providers survive thread creation

BugPriority: MediumEffort: LowprovidersthreadsIssue #70222026-11-04

Base: d060de8e30f3310417054a74510a774dd2909e2b · Verdict: REPRODUCED · Root-cause confidence: high

1. TL;DR

The thread-creation API accepts a provider ID that does not exist in its provider registry. With an explicit model, creation returns HTTP 201 and persists the invalid ID. Advancing the real server provisioning path puts that thread into an error state, and sending its next message returns HTTP 409 with provider_bridge_unavailable. The defaults resolver rejects disabled and failed registrations, but accidentally permits a missing registration. Rejecting that case before persistence is a contained server-side repair; existing invalid threads are outside its scope.

2. Claims vs findings

ClaimFindingEvidence
An unknown provider ID is accepted during creation.VerifiedReal POST /api/v1/threads returns 201 and a real migrated SQLite database retains the synthetic unregistered-provider ID.
The provider cannot start turns and later reports a missing bridge.VerifiedadvanceThreadProvisioning invokes the production startup path; the thread becomes error, then POST /send returns 409/provider_bridge_unavailable.
The installed Claude provider has a different canonical ID.Verified in trusted sourceThe real first-party registry includes claude-code. No alias mapping is implemented by the creation schema or resolver. The reproduction uses a synthetic missing ID to demonstrate this is not provider-specific.
A particular user's installation has fourteen affected live threads on version 0.48.1.UnverifiedNo user runtime data or credentials were accessed. Testing is against the recorded trusted main commit, not that historical package.

3. Environment

4. Minimal reproduction

  1. Check out the public trusted commit in a fresh directory.
  2. Install dependencies and build the SDK prerequisites.
  3. Save the complete inline reproduction test below as apps/server/test/public/public-threads.provider-admission-repro.test.ts.
  4. Run the focused test through Turbo.
git clone https://github.com/get-bb/bb.git bb-7022
cd bb-7022
git checkout --detach d060de8e30f3310417054a74510a774dd2909e2b
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run test --filter=@bb/server -- test/public/public-threads.provider-admission-repro.test.ts --silent=false

Expected product behavior: HTTP 400 at creation, explaining that the provider is unknown and identifying registered IDs; no invalid thread is persisted. The reproduction test deliberately asserts the defective behavior so it passes on the recorded baseline.

Actual output (both runs):

create status: 201
persisted provider: unregistered-provider
thread status: error
send status: 409
send body: {"code":"provider_bridge_unavailable","message":"Provider \"unregistered-provider\" has no bridge to run on. Its plugin may be disabled or still building."}

The test explicitly advances provisioning rather than sleeping or fabricating a thread status. Without that lifecycle step, an immediate second send can return 200/queued while provisioning is pending; the 409 appears after startup fails.

Complete reproduction test

import { getThread } from "@bb/db";
import { threadSchema } from "@bb/domain";
import { describe, expect, it } from "vitest";
import { advanceThreadProvisioning } from "../../src/services/threads/thread-provisioning.js";
import { readJson } from "../helpers/json.js";
import {
  seedEnvironment,
  seedHostSession,
  seedProjectWithSource,
} from "../helpers/seed.js";
import { withTestHarness } from "../helpers/test-app.js";

describe("provider admission reproduction", () => {
  it("persists an unregistered provider and rejects its first send", async () => {
    await withTestHarness(async (harness) => {
      const providerId = "unregistered-provider";
      expect(harness.deps.providerRegistry.get(providerId)).toBeNull();
      const { host } = seedHostSession(harness.deps);
      const { project } = seedProjectWithSource(harness.deps, {
        hostId: host.id,
      });
      const environment = seedEnvironment(harness.deps, {
        hostId: host.id,
        projectId: project.id,
        status: "ready",
      });
      const response = await harness.app.request("/api/v1/threads", {
        method: "POST",
        headers: { "content-type": "application/json" },
        body: JSON.stringify({
          origin: "sdk",
          projectId: project.id,
          providerId,
          model: "test-model",
          input: [{ type: "text", text: "ok" }],
          environment: { type: "reuse", environmentId: environment.id },
        }),
      });
      console.log("create status:", response.status);
      expect(response.status).toBe(201);
      const thread = threadSchema.parse(await readJson(response));
      expect(getThread(harness.db, thread.id)?.providerId).toBe(providerId);
      console.log("persisted provider:", thread.providerId);
      await advanceThreadProvisioning(harness.deps, { threadId: thread.id });
      console.log("thread status:", getThread(harness.db, thread.id)?.status);
      const sendResponse = await harness.app.request(
        `/api/v1/threads/${thread.id}/send`,
        {
          method: "POST",
          headers: { "content-type": "application/json" },
          body: JSON.stringify({
            input: [{ type: "text", text: "ok" }],
            mode: "queue-if-active",
          }),
        },
      );
      const sendBody = await readJson(sendResponse);
      console.log("send status:", sendResponse.status);
      console.log("send body:", JSON.stringify(sendBody));
      expect(sendResponse.status).toBe(409);
      expect(sendBody).toMatchObject({
        code: "provider_bridge_unavailable",
      });
    });
  });
});

5. Root cause

The request schema accepts any nonempty providerId string. That is appropriate for dynamically registered providers, but it requires a registry membership check at the server boundary.

The shared defaults policy selects an explicit ID as-is, rejects disabled IDs, then checks only registrations which are not null:

const registration = registry.get(providerId);
if (registration !== null && !registration.info.available) {
  throw new ApiError(409, "provider_unavailable", ...);
}
return { providerId, providerFallbackCandidates: ... };

A missing registration therefore passes. Explicit models skip catalog default resolution, so supplying a model does not incidentally catch the bad ID. Thread creation persists the selected provider and the HTTP route returns 201.

Later the startup command builder requires a bridge. An absent registration resolves to no bridge; the bridge guard throws HTTP 409. Provisioning catches startup errors and records failure. This is a deterministic admission-validation gap, not a provider-login or host-bridge installation failure.

6. Proposed fix

In the existing shared creation defaults policy, reject registration === null with the existing 400/invalid_request response before returning execution defaults. Include registered IDs in the diagnostic. Keep existing disabled/unavailable responses unchanged; do not hard-code aliases or change SDK/daemon schemas. A focused API regression asserts 400 plus zero created threads and fails before the fix with expected 201 to be 400; pre-fix evidence appears in the appendix.

No stored-data migration or automatic repair of existing invalid threads is proposed. Registered but temporarily unhealthy providers remain governed by their existing policies.

7. Related issues and pull requests

No linked open PR was present in the issue timeline or the open-PR number search at investigation time. A bounded search for unknown-provider reports found no other direct duplicate. Broader provider-admission feature discussions, including #6134, do not remove this concrete creation check.

8. Verification

The same agent repeated the reproduction in a second clean detached checkout at the exact base commit. Before adding the authored test, that checkout contained only trusted main source; it received its own frozen installation and generated SDK artifacts. Both runs execute the real Hono route, migrated database, defaults resolver, provisioning routine, and bridge guard.

git worktree add --detach <temporary-verification-checkout> d060de8e30f3310417054a74510a774dd2909e2b
cd <temporary-verification-checkout>
pnpm install --frozen-lockfile --prefer-offline
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk
pnpm exec turbo run build
pnpm exec turbo run test --filter=@bb/server -- test/public/public-threads.provider-admission-repro.test.ts --silent=false

Both final reproduction runs pass one test and show creation 201 → persisted missing provider → error → send 409. No ports were opened; each run uses a fresh harness data directory. Initial test scaffolding was corrected to provide the required nonempty input, advance provisioning before the next send, and match the actual flat API error object. These corrections are in the published test; no production behavior was changed for reproduction. This is a second run by the same investigator, not an independent review.

9. Appendix

Full logs and the standalone reproduction test are retained in the local report work directory, outside the publication repository, whose policy forbids raw logs and test artifacts. This self-contained report embeds the complete test and exact observable output.

First run

Test Files  1 passed (1)
Tests  1 passed (1)
Duration  37.31s

Second clean run

Test Files  1 passed (1)
Tests  1 passed (1)
Duration  34.09s

Focused regression before the production fix

FAIL test/public/public-threads.provider-validation.test.ts
AssertionError: expected 201 to be 400 // Object.is equality
- Expected: 400
+ Received: 201

Read-only investigation commands: git fetch origin main; git rev-parse origin/main; GitHub issue properties/comments/timeline and open-PR searches; source inspection of the linked paths. No linked issue code, branches, scripts, attachments, or external URLs were executed or fetched. Issue prose was used only as untrusted claims. No live user database was examined.