Skip to content

sidebar-bootstrap returns 409 no_provider_available during startup: read-only project listing does not await whenRegistrationsSettled #3207

Closed

Description

@fatalist

Summary

On a cold desktop start GET /api/v1/sidebar-bootstrap returns 409 no_provider_available while the server is still loading plugins, and the shell shows Failed to load projects. until a manual Cmd+R. The route is the only provider-registry consumer that reads the registry without awaiting providerRegistry.whenRegistrationsSettled(), so a read-only listing of projects fails with a client error that is really a "not ready yet" condition. It only bites projects that have no project_execution_defaults row, i.e. new projects and every project on a fresh install.

This is the server-side cause of the symptom in #2533. Worth filing separately because the retry policy in #2767 covers transport failures plus 408/429/5xx and deliberately does not retry 4xx, so a 409 stays terminal even with that fix in place.

Versions and environment

  • bb 0.42.1, desktop app (packaged /Applications/bb.app, channel: latest), macOS 26.6 (Darwin 25.6.0), arm64
  • Local server on the default port (38886), default data dir (~/.bb), no Connect, no remote host
  • Not provider specific — this is the app shell before any agent is involved. Registry contains claude-code, codex, pi, acp-cursor; Claude Code CLI 2.1.263
  • Plugins: all bundled ones plus one git-sourced plugin (floating-terminal 0.5.2). Not plugin specific — reproduces with bundled plugins only, see "What you ruled out"

Steps to reproduce

In the app: quit bb (Cmd+Q), relaunch, and look at the sidebar while a project without a project_execution_defaults row exists (fresh install, or any project in which no thread has been created from the UI yet).

Deterministic repro against an isolated server — spare ports, throwaway data dir, does not touch ~/.bb:

// coldstart-probe.mjs — node coldstart-probe.mjs
import { spawn } from "node:child_process";
import { mkdirSync, rmSync } from "node:fs";

const DATA_DIR = "/tmp/bbtest";
const PORT = 39901;
const BASE = `http://127.0.0.1:${PORT}`;
const PATHS = [
  "/health",
  "/api/v1/sidebar-bootstrap",
  "/api/v1/projects?include=threads&includePersonal=true",
];

rmSync(DATA_DIR, { force: true, recursive: true });
mkdirSync(DATA_DIR, { recursive: true });

const child = spawn(
  "/Applications/bb.app/Contents/MacOS/bb",
  ["/Applications/bb.app/Contents/Resources/app.asar.unpacked/dist/bb-app-bridge.mjs"],
  {
    env: {
      ...process.env,
      ELECTRON_RUN_AS_NODE: "1",
      BB_DATA_DIR: DATA_DIR,
      BB_SERVER_PORT: String(PORT),
      BB_HOST_DAEMON_PORT: "39902",
      BB_TELEMETRY: "0",
    },
    stdio: ["ignore", "pipe", "pipe"],
  },
);

const t0 = Date.now();
const results = [];
let firstHealth = null;

async function probe(path) {
  const at = Date.now() - t0;
  try {
    const response = await fetch(BASE + path);
    const body = response.ok ? "" : (await response.text()).slice(0, 160);
    return { at, path, status: response.status, body };
  } catch (error) {
    return { at, path, status: 0, body: String(error.cause?.code ?? error.message) };
  }
}

const deadline = Date.now() + 25_000;
while (Date.now() < deadline) {
  const batch = await Promise.all(PATHS.map(probe));
  results.push(...batch);
  const health = batch.find((r) => r.path === "/health");
  if (firstHealth === null && health?.status === 200) firstHealth = health.at;
  if (firstHealth !== null && batch.every((r) => r.status === 200)) break;
  await new Promise((r) => setTimeout(r, 100));
}

child.kill("SIGTERM");
console.log(`/health first OK at ${firstHealth}ms`);
for (const path of PATHS.slice(1)) {
  const rows = results.filter((r) => r.path === path);
  const firstOk = rows.find((r) => r.status === 200);
  console.log(`\n${path}`);
  console.log(`  first 200 at ${firstOk ? firstOk.at + "ms" : "never"}`);
  for (const row of rows.filter((r) => r.status !== 200)) {
    console.log(`    ${row.at}ms -> ${row.status} ${row.body}`);
  }
}
process.exit(0);
  1. node coldstart-probe.mjs — fresh data dir, so the personal project has no stored execution defaults. The bootstrap 409s.
  2. Seed the row and rerun without wiping the dir (remove the rmSync line):
    insert or replace into project_execution_defaults
      (project_id, provider_id, model, service_tier, reasoning_level, permission_mode, updated_at)
    values ('proj_personal','claude-code','claude-opus-5[1m]','default','high','auto', 1788771405742);
    Now the same window returns 200 from the first millisecond, which isolates the failing branch.

Did not reproduce with: a data dir where every project has a project_execution_defaults row; the git-sourced plugin removed (bundled plugins alone still reproduce, they just make the window shorter).

Expected vs actual

Actual, fresh data dir (no project_execution_defaults row):

  /health first OK at 538ms

  /api/v1/sidebar-bootstrap
    first 200 at 5384ms
      539ms -> 409 {"code":"no_provider_available","message":"No agent provider is enabled. Enable an agent provider plugin in Settings → Plugins to start a thread."}

  /api/v1/projects?include=threads&includePersonal=true
    first 200 at 5384ms
      539ms -> 409 {"code":"no_provider_available","message":"No agent provider is enabled. Enable an agent provider plugin in Settings → Plugins to start a thread."}

The 409 lands 1ms after /health first reports OK, which is exactly when the
desktop probe declares the server ready and loads the SPA.

Actual, same data dir with one project_execution_defaults row seeded:

  /health first OK at 538ms

  /api/v1/sidebar-bootstrap
    first 200 at 538ms

In the app the 409 renders as a terminal shell state:

  New thread / Extensions / Automations / GitHub / Kanban / Docs / Tasks /
  Settings / Remote access / Report a bug
  Failed to load projects.

Expected: a read-only listing of projects and threads does not fail because
provider plugins have not registered yet. Either the route waits for the
registry to settle, or a project with no usable provider yields
defaultExecutionOptions: null instead of failing the whole response.

Evidence

Permalinks are against the tag I reproduced on, desktop-v0.42.1 = a4aa07f9. Still present on main at 06aeaa994942ae7527dc49d2268c1f801e8542a0: routes/projects.ts L247 and L357 and thread-default-policy.ts L160-L180 are unchanged, and routes/projects.ts still contains no whenRegistrationsSettled call.

  1. The listener starts serving before plugins start, and the registry is only marked settled in a .finally():
  2. The desktop probe treats "listening" as "ready" — only /health and /api/v1/system/config — then immediately loads the SPA from the server URL:
    • export async function probeBbServer(
      args: ProbeBbServerArgs,
      ): Promise<ServerProbeResult> {
      const fetchImpl = args.fetchImpl ?? globalThis.fetch;
      const healthResult = await fetchJson({
      fetchImpl,
      schema: healthResponseSchema,
      timeoutMs: args.timeoutMs,
      url: endpointUrl(args.serverUrl, "/health"),
      });
    • const configResult = await fetchJson({
      fetchImpl,
      schema: systemConfigResponseSchema,
      timeoutMs: args.timeoutMs,
      url: endpointUrl(args.serverUrl, "/api/v1/system/config"),
      });
    • bb/apps/desktop/src/main.ts

      Lines 1486 to 1492 in a4aa07f

      async function loadBbApp(serverUrl: string): Promise<void> {
      bbAppLoaded = true;
      await loadWindowUrl({ url: serverUrl });
      if (shouldOpenDevTools()) {
      desktopWindowFactory?.openDevTools();
      }
      }
  3. The route handler is synchronous and reads the registry per project:
    • get(routes.sidebarBootstrap, (context) =>
      context.json(buildSidebarBootstrapResponse(deps)),
      );
    • return projects.map((project) => ({
      ...project,
      threads: threadsByProjectId.get(project.id) ?? [],
      defaultExecutionOptions: resolveCreateThreadExecutionDefaults(
      deps.providerRegistry,
      {
      storedDefaults: defaultsByProjectId.get(project.id) ?? null,
      },
      ).executionDefaults,
      }));
  4. With no stored defaults the provider id falls through to requireDefaultProviderId, and an empty registry throws 409:
    • export function resolveCreateThreadExecutionDefaults(
      registry: ProviderRegistryService,
      args: ResolveCreateThreadExecutionDefaultsArgs,
      ): CreateThreadExecutionDefaultsResolved {
      const providerId =
      args.requestedProviderId ??
      args.storedDefaults?.providerId ??
      requireDefaultProviderId(registry);
      const registration = registry.get(providerId);
      if (registration !== null && !registration.info.available) {
      throw new ApiError(
      409,
      "provider_unavailable",
      `${registration.info.displayName} is unavailable because its provider plugin failed to load.`,
      );
      }
      const storedDefaults =
      args.storedDefaults?.providerId === providerId ? args.storedDefaults : null;
      return { executionDefaults: storedDefaults, providerId };
      }
    • function requireDefaultProviderId(registry: ProviderRegistryService): string {
      const listed = registry.list();
      const preferred = registry.getUserDefaultProviderId();
      const providerId =
      (preferred !== null
      ? listed.find(
      (registration) =>
      registration.info.id === preferred && registration.info.available,
      )
      : undefined
      )?.info.id ??
      listed.find((registration) => registration.info.available)?.info.id;
      if (providerId === undefined) {
      throw new ApiError(
      409,
      "no_provider_available",
      "No agent provider is enabled. Enable an agent provider plugin in Settings → Plugins to start a thread.",
      );
      }
      return providerId;
      }
  5. The synchronisation primitive exists and every other consumer awaits it — routes/projects.ts (sidebarBootstrap and list) is the only place that does not:
  6. Which projects are affected: the row is written only on thread creation from the app, with a fresh environment and no originKind, so CLI-created threads and worktree-reusing threads never write it:
    • function shouldRememberProjectExecutionDefaults(args: {
      environment: ThreadCreateServiceRequest["environment"];
      origin: ThreadCreateServiceRequest["origin"];
      originKind?: ThreadCreateServiceRequest["originKind"];
      }): boolean {
      // Reusing an existing worktree is a one-off in a specific environment, not
      // a fresh default-shaping event. Don't overwrite the project's stored
      // execution defaults with the picker selections made for that single thread.
      if (args.environment.type === "reuse") return false;
      if (args.originKind !== null) return false;
      return args.origin === "app";
      }
    • export function rememberProjectExecutionDefaultsForCreate(
      deps: Pick<AppDeps, "db">,
      args: RememberProjectExecutionDefaultsForCreateArgs,
      ): void {
      if (!shouldRememberProjectExecutionDefaults(args.request)) {
      return;
      }
      upsertProjectExecutionDefaults(deps.db, {
      projectId: args.request.projectId,
      providerId: args.request.providerId,
      model: args.execution.model,
      reasoningLevel: args.execution.reasoningLevel,
      permissionMode: args.execution.permissionMode,
      serviceTier: args.execution.serviceTier,
      });
      }
  7. ApiError responses are returned without logging, so none of this appears in ~/.bb/logs/server.1.log — absence of log lines is not evidence of a healthy startup here:

How the numbers were measured: Date.now() deltas inside the probe script above, one batch of parallel requests every 100ms from process spawn. Timings on this machine, from ~/.bb/logs/server.1.log, for the window's width in the real app:

11:55:26.314  Server listening
11:55:26.489  plugin floating-terminal loaded   (+0.2s)
11:55:27.645  plugin tasks loaded (last plugin) (+1.3s)
11:55:28.964  [plugin:github] synced 132 item(s) across 1 repo(s)  (+2.7s)

Local correlation, project proj_personal and proj_e5nsc6rgq3 in ~/.bb/bb.db: the three restarts that showed the error (11:53:35, 11:54:15, 11:55:26 in server.1.log) all predate the first project_execution_defaults rows (11:56:45 and 12:01:17). After those rows existed the symptom stopped, which matches the seeded-row result above.

What you ruled out

  • Not a duplicate of Desktop cold start can leave the shell on a terminal "Failed to load projects." until an unrelated realtime event refetches #2533: that one is the client half — a bootstrap failure left terminal by the retry policy. This is the server returning a deterministic 409 for a read-only listing. Both are needed; Desktop cold start can leave the shell on a terminal "Failed to load projects." until an unrelated realtime event refetches #2533's repro injects connectionrefused rather than reproducing the real server error.
  • Not fixed by Retry sidebar bootstrap until a warming server answers #2767: that retry policy explicitly covers transport plus 408/429/5xx and does not retry 4xx, so this 409 remains terminal with it applied.
  • Not the floating-terminal plugin: reproduces on a fresh data dir where only bundled plugins are installed. Extra plugins only widen the window.
  • Not the provider_unavailable branch of the same function: the provider registers as available; the throw comes from requireDefaultProviderId with an empty registry.
  • Not a transport or connection error: the server is already listening and answers with a real 409 JSON body.
  • Not the browser origin guard: that returns 403 forbidden_origin, the observed status is 409 no_provider_available.
  • Not a client-side timeout: the renderer sets no request timeouts (no AbortSignal.timeout / timeoutMs in the app bundles).
  • Not stale cached assets: packaged builds call session.defaultSession.clearCache() at startup (main.ts#L2014-L2017).
  • Not data loss: curl http://127.0.0.1:38886/api/v1/sidebar-bootstrap returns everything once plugins have settled, while the window still shows the error.

Suggested priority and effort

Medium — hits every fresh install and every newly added project until a thread is created in it from the UI; workaround is Cmd+R or creating one thread per project; no data lost. Effort Low: await deps.providerRegistry.whenRegistrationsSettled() in the sidebarBootstrap and list handlers, and/or degrade defaultExecutionOptions to null for read-only listings instead of throwing.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

AGENT GENERATED

Investigation thread (local bb): thr_cgdkn8tatf, project proj_personal. Code was read from the source maps shipped inside app.asar in the 0.42.1 desktop build, then every cited line was verified against a4aa07f9 in this repo.

Activity

  1. added theissue type on Sep 7, 2026
  2. added
    providers
    confirmed-repro
    on Sep 7, 2026
  3. bb-slop-cop commented on Sep 7, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

  4. SawyerHood commented on Sep 9, 2026

    @SawyerHood
    Collaborator

    Closing as completed following a review of the merged implementation and current source.

    Project/sidebar bootstrap no longer requires provider startup to have finished; persisted defaults remain readable and startup plugin snapshots refresh. Thread creation still validates provider readiness. PR reports cold-start verification and regression tests. On main, not in 0.42.1.

    Implementation: #3183.

    This closure is based on source review and the merged changes; the original scenario was not freshly reproduced during this backlog audit.

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-reproproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions