From 8da37013aecb918a27a12aae91c25e4384d77cb2 Mon Sep 17 00:00:00 2001 From: Mahima Shanware Date: Fri, 17 Apr 2026 18:22:16 +0000 Subject: [PATCH] fix(core): add ENOENT fallback to resolveWorkspaceRelativePath for JIT provisioning --- packages/core/src/config/storage.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/core/src/config/storage.ts b/packages/core/src/config/storage.ts index f82e1654a5..5e8cfda26b 100644 --- a/packages/core/src/config/storage.ts +++ b/packages/core/src/config/storage.ts @@ -352,9 +352,22 @@ export class Storage { const realProjectRoot = resolveToRealPath(this.getProjectRoot()); // By enforcing resolveToRealPath, we guarantee symlinks are evaluated. - // If the path doesn't exist, this will throw an error, strictly preventing - // traversal vulnerabilities via missing symlinks or permission gaps. - const realResolvedPath = resolveToRealPath(resolvedPath); + // If the path doesn't exist, we fallback to string normalization (JIT provisioning). + let realResolvedPath: string; + try { + realResolvedPath = resolveToRealPath(resolvedPath); + } catch (error: unknown) { + if ( + typeof error === 'object' && + error !== null && + 'code' in error && + error.code === 'ENOENT' + ) { + realResolvedPath = path.normalize(resolvedPath); + } else { + throw error; + } + } if (!isSubpath(realProjectRoot, realResolvedPath)) { throw new Error(