From db02da69baac26903b2d4880231f20d78882379f Mon Sep 17 00:00:00 2001 From: Ben Davis Date: Mon, 23 Mar 2026 19:12:50 -0700 Subject: [PATCH] Handle missing workspace directories when creating folders - Treat NotFound as the only acceptable inspect failure - Return a clearer error for unexpected filesystem inspection failures --- apps/server/src/wsServer.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/server/src/wsServer.ts b/apps/server/src/wsServer.ts index 1b1d560d1b..744991cc4c 100644 --- a/apps/server/src/wsServer.ts +++ b/apps/server/src/wsServer.ts @@ -35,6 +35,7 @@ import { FileSystem, Layer, Path, + PlatformError, Ref, Result, Schema, @@ -790,6 +791,17 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< message: `Workspace directory already exists: ${target.relativePath}`, }); } + if ( + !( + existingEntry.failure instanceof PlatformError.PlatformError && + existingEntry.failure.reason instanceof PlatformError.SystemError && + existingEntry.failure.reason._tag === "NotFound" + ) + ) { + return yield* new RouteRequestError({ + message: `Failed to inspect workspace directory: ${String(existingEntry.failure)}`, + }); + } yield* fileSystem .makeDirectory(path.dirname(target.absolutePath), { recursive: true })