From 00476714588cefa8600b7f016242464da05c4211 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 16:51:28 +0000 Subject: [PATCH] fix(api): check scanned project folders before creating their projects The onboarding scan resolved each repository with realpath and left the remaining checks to wireProjectWorkspace, which ran them only after the project had been created. wireProjectWorkspace now stores the folder it is given, so the scan resolves and checks the folder with resolveProjectWorkspaceDirectory first, like spaces.create, and skips a repository whose folder cannot be linked before creating its project. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012HG4pFTUBDpuCS2Y44TV8x --- apps/api/src/onboarding-scan.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/api/src/onboarding-scan.ts b/apps/api/src/onboarding-scan.ts index 765336b..bad1aa8 100644 --- a/apps/api/src/onboarding-scan.ts +++ b/apps/api/src/onboarding-scan.ts @@ -1,13 +1,14 @@ // Onboarding scan — real filesystem scan, Git analysis, and profile compilation. // Runs synchronously on the host machine (no sandbox needed). import { spawn } from "node:child_process"; -import { access, readdir, realpath, stat } from "node:fs/promises"; +import { access, readdir, stat } from "node:fs/promises"; import { basename, dirname, join } from "node:path"; import type { Actor } from "@rakazo/contracts"; import type { PrismaClient } from "@rakazo/db"; import { createSpaceForMember, InvalidSpaceNameError, + resolveProjectWorkspaceDirectory, SpaceLimitError, wireProjectWorkspace, } from "@rakazo/db"; @@ -656,7 +657,8 @@ async function createProjects( for (const repo of repos) { // Compare and link the real folder, so the next scan recognizes the projects of this one. - const folder = await realpath(repo.path).catch(() => null); + // Checking it before the project exists means a folder that cannot be linked leaves none. + const folder = await resolveProjectWorkspaceDirectory(repo.path).catch(() => null); if (!folder || linkedFolders.has(folder)) continue; let space: { id: string; name: string }; try {