diff --git a/src/commands/sandbox.test.ts b/src/commands/sandbox.test.ts index bf8624b8ffaf..1cb22beac9db 100644 --- a/src/commands/sandbox.test.ts +++ b/src/commands/sandbox.test.ts @@ -169,12 +169,15 @@ describe("sandboxListCommand", () => { }); describe("error handling", () => { - it("should handle errors gracefully", async () => { + it("propagates backend probe failures instead of rendering an empty list", async () => { mocks.listSandboxContainers.mockRejectedValue(new Error("Docker not available")); - await sandboxListCommand({ browser: false, json: false }, runtime as never); - - expect(runtime.log).toHaveBeenCalledWith("No sandbox runtimes found."); + // A failing probe must reach the CLI error path (message + exit 1), + // not masquerade as "No sandbox runtimes found." + await expect( + sandboxListCommand({ browser: false, json: false }, runtime as never), + ).rejects.toThrow("Docker not available"); + expect(runtime.log).not.toHaveBeenCalledWith("No sandbox runtimes found."); }); }); }); diff --git a/src/commands/sandbox.ts b/src/commands/sandbox.ts index 8acc8451e153..4db48df268a2 100644 --- a/src/commands/sandbox.ts +++ b/src/commands/sandbox.ts @@ -51,8 +51,10 @@ export async function sandboxListCommand( opts: SandboxListOptions, runtime: RuntimeEnv, ): Promise { - const containers = opts.browser ? [] : await listSandboxContainers().catch(() => []); - const browsers = opts.browser ? await listSandboxBrowsers().catch(() => []) : []; + // A failing backend/registry probe must surface, not render as an empty + // list that reads as "no sandboxes". + const containers = opts.browser ? [] : await listSandboxContainers(); + const browsers = opts.browser ? await listSandboxBrowsers() : []; if (opts.json) { writeRuntimeJson(runtime, { containers, browsers }); @@ -121,8 +123,8 @@ function validateRecreateOptions(opts: SandboxRecreateOptions, runtime: RuntimeE } async function fetchAndFilterContainers(opts: SandboxRecreateOptions): Promise { - const allContainers = await listSandboxContainers().catch(() => []); - const allBrowsers = await listSandboxBrowsers().catch(() => []); + const allContainers = await listSandboxContainers(); + const allBrowsers = await listSandboxBrowsers(); let containers = opts.browser ? [] : allContainers; let browsers = opts.browser ? allBrowsers : [];