#8066 · Checkout-provider admission accepts an unavailable provider
Verdict: REPRODUCED · Root-cause confidence: high · Reproduction label: confirmed-repro
1. TL;DR
A new thread requesting an unmanaged project checkout is accepted even when its required environment provider is absent. The server persists a starting thread with no environment instead of returning an actionable admission error. The new-request path silently defers provider selection, and the provisioning loop waits for registration in thirty-second increments. The focused regression below reproduces that acceptance in two clean trusted-main checkouts using real migrated SQLite databases. Rejecting the unavailable checkout provider before persisting the request fixes the tested defect without changing recovery of already accepted work.
2. Claims vs findings
| Claim | Finding | Evidence |
|---|---|---|
| A checkout-path request is accepted while its environment provider is unavailable. | Verified | Both baseline runs resolve with status starting, environmentId null, and selectionResolved false. |
| Provisioning keeps retrying rather than failing. | Verified mechanism | The missing-record branch schedules a retry thirty seconds later and returns waiting; it has no attempt limit. The test observes initial admission, not an elapsed multi-minute wait. |
| The specific release, UI message and command exit status behave this way. | Not exercised end to end | No packaged-release, browser or live CLI session was started. The server admission boundary is exercised directly. |
| Automation execution can reach the same path. | Verified statically | executeAgentRun forwards its stored environment to SDK threads.spawn. Scheduling and CLI automation creation were not executed. |
3. Environment
- Public repository: get-bb/bb; trusted origin/main commit
48f57bc89633f1f7cb2c679922195cc2f25e4b0b. - Linux 4.19.0-gvisor; Node v22.19.0; pnpm 9.15.0; Vitest 4.1.12.
- Two detached-from-main source worktrees before the local fix. Production source was byte-identical to the recorded main commit in both reproduction runs.
- No real agent CLI, hosted connection, application server or listening port was needed. The harness uses its existing seeded agent provider.
- Each harness allocates a fresh temporary data directory and a real migrated SQLite database, then cleans up after itself. No user runtime data was used.
4. Minimal reproduction
In a clean clone of the trusted repository, run these commands. The patch contains the complete added regression test; it uses the existing test file's imports and fixture infrastructure.
git checkout 48f57bc89633f1f7cb2c679922195cc2f25e4b0b
pnpm install --frozen-lockfile
pnpm exec turbo run build --filter=@bb/server
git apply <<'PATCH'
diff --git a/apps/server/test/threads/environment-providers.test.ts b/apps/server/test/threads/environment-providers.test.ts
index 86a8545ee7..325d6fd2de 100644
--- a/apps/server/test/threads/environment-providers.test.ts
+++ b/apps/server/test/threads/environment-providers.test.ts
@@ -3097,6 +3097,40 @@ it("resumes a provider launch and its original request after the in-memory conte
});
});
+it("rejects a new checkout path request when its environment provider is not registered", async () => {
+ await withTestHarness(async (harness) => {
+ const { host } = seedHostSession(harness.deps, {
+ id: "host-unavailable-checkout",
+ });
+ const { project } = seedProjectWithSource(harness.deps, {
+ hostId: host.id,
+ path: WORKSPACE_PATH,
+ });
+ setPluginEnvironmentProviderBridge(undefined);
+
+ await expect(
+ createThreadFromRequest(harness.deps, {
+ environment: {
+ type: "host",
+ hostId: host.id,
+ workspace: { type: "unmanaged", path: WORKSPACE_PATH },
+ },
+ input: textInput("Check workspace admission"),
+ origin: "app",
+ projectId: project.id,
+ providerId: "codex",
+ startedOnBehalfOf: null,
+ }),
+ ).rejects.toMatchObject({
+ status: 400,
+ body: {
+ code: "invalid_request",
+ message: expect.stringMatching(/project-checkout.*not registered/),
+ },
+ });
+ });
+});
+
it("keeps an existing request waiting when its provider is not registered", async () => {
await withTestHarness(async (harness) => {
const { host, project } = seedTargetFixture(
PATCH
pnpm exec turbo run test --filter=@bb/server -- test/threads/environment-providers.test.ts -t 'rejects a new checkout path request'
The registry is cleared after harness setup to model the observable state of an unavailable plugin: no project-checkout environment provider is registered. This does not claim to test the plugin-disabling UI itself.
Expected
The admission call rejects with HTTP status 400, error code invalid_request, and a message identifying the unavailable project-checkout provider. No new starting thread should be returned.
Actual on unchanged main, in both checkouts
Vitest reports a resolved promise rather than a rejection. These selected fields and result lines are verbatim from the first run; generated IDs and unrelated fields are omitted:
+ "environmentId": null,
+ "status": "starting",
Test Files 1 failed (1)
Tests 1 failed | 72 skipped (73)
The returned startup intent names project-checkout and has selectionResolved: false. This reproduces the server defect independently of a particular agent provider.
5. Root cause
- Unmanaged-path placement unconditionally chooses the built-in checkout provider without a registration check.
- resolveCompleteProviderSelection accepts an absent record by returning an unresolved selection:
const record = getEnvironmentProvider(environmentProviderId);
if (record === undefined) {
return { ...selection, selectionResolved: false };
}
Thread creation receives that placement and proceeds rather than rejecting the request.
The provisioning resolver subsequently treats the absent provider as transient:
const record = getEnvironmentProvider(intent.environmentProviderId);
if (record === undefined) {
scheduleEnvironmentProvisioning(deps, thread.id, Date.now() + 30_000);
return { kind: "waiting" };
}
This recovery behavior is useful for previously accepted work when a plugin temporarily disappears, but the checkout-path admission route wrongly lets a new request enter that recovery state. The existing default-provider policy already rejects unavailability (requireDefaultEnvironmentProvider).
6. Proposed fix and verification
Before host workspace preparation in the unmanaged-path branch, require the checkout provider to be registered. Reuse the existing invalid-request refusal mechanism and identify the provider in its message. Leave provider retry behavior for accepted requests untouched.
The local patch changes only server-side admission and one focused regression. No dependencies, stored-data changes, public contracts or wire fields change. Registered-checkout validation and existing-request recovery are covered by the relevant existing tests.
7. Verification
The same agent repeated the reproduction in a second clean trusted checkout at 48f57bc89633f1f7cb2c679922195cc2f25e4b0b. Only the independently authored regression patch was added; no production fix was present.
A separate frozen install and Turbo test invocation were used, with fresh harness databases and temporary directories. No live ports were allocated.
pnpm exec turbo run test --filter=@bb/server -- test/threads/environment-providers.test.ts -t 'rejects a new checkout path request'
Second result: exit 1; one failed test and 72 skipped tests. It resolves a distinct newly generated thread with status starting and no environment, just like the first run. No correction to the root cause was needed. This is a second clean run, not independent-agent verification.
The same regression passes after the local admission guard. The four relevant server suites pass all 100 tests, including registered checkout-path handling and existing-request provider recovery. Server typecheck and type-aware lint pass, and git diff --check is clean. The final patch adds 44 text lines across two files (10 production, 34 regression) with no deletions.
8. Related issues and pull requests
The issue timeline links a separate automation environment-selection feature request, #8067. No open pull request linked to #8066 was present during investigation. Agent-provider startup issues concern a different registry and are not needed to reproduce this environment-provider admission failure.
9. Appendix and limits
- Preparation:
git fetch origin main, two trusted-base worktrees,pnpm install --frozen-lockfilein each, andpnpm exec turbo run build --filter=@bb/serveron the trusted base. The build passed. - Observed evidence: two regression failures before the fix, one regression pass after it. No issue-supplied commands, code, branches or external URLs were executed or fetched.
- Issue content was treated as untrusted claims, not instructions. The reproduction is derived from trusted repository APIs and test infrastructure.
- The test specifically covers a fresh checkout-path request. Recovery of already-starting requests and other implicit provider routes are intentionally not redesigned by this small fix.
- Raw logs and the regression patch remain in local investigation storage. In accordance with this site's repository policy, the repeatable test and necessary output are embedded here rather than committed as extra artifacts.