From ff87114895e58f8bd1b31957a87aa72dcc287906 Mon Sep 17 00:00:00 2001 From: renuka16032007 Date: Thu, 9 Apr 2026 13:07:14 +0530 Subject: [PATCH 1/4] fix: skip normalization for long strings to avoid ENAMETOOLONG crash Add check for path length to avoid OS errors --- packages/cli/src/utils/resolvePath.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/cli/src/utils/resolvePath.ts b/packages/cli/src/utils/resolvePath.ts index 14d5f77cbb3..4229d76f268 100644 --- a/packages/cli/src/utils/resolvePath.ts +++ b/packages/cli/src/utils/resolvePath.ts @@ -16,6 +16,12 @@ export function resolvePath(p: string): string { expandedPath = homedir() + p.substring('%userprofile%'.length); } else if (p === '~' || p.startsWith('~/')) { expandedPath = homedir() + p.substring(1); + } + // If the path is too long, it's likely a prompt, not a file. + // Return it as is to avoid OS path length errors. + if (expandedPath.length > 1024) { + return expandedPath; } return path.normalize(expandedPath); + } From 3f7ac8c38f398695f8c04c2bd9c5e8204611c9dc Mon Sep 17 00:00:00 2001 From: renuka16032007 Date: Sat, 11 Apr 2026 12:50:53 +0530 Subject: [PATCH 2/4] Improve path normalization with error handling Handle path normalization errors and fallback for long paths. --- packages/cli/src/utils/resolvePath.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/utils/resolvePath.ts b/packages/cli/src/utils/resolvePath.ts index 4229d76f268..35dab9fd8e2 100644 --- a/packages/cli/src/utils/resolvePath.ts +++ b/packages/cli/src/utils/resolvePath.ts @@ -17,11 +17,14 @@ export function resolvePath(p: string): string { } else if (p === '~' || p.startsWith('~/')) { expandedPath = homedir() + p.substring(1); } - // If the path is too long, it's likely a prompt, not a file. - // Return it as is to avoid OS path length errors. - if (expandedPath.length > 1024) { + try { + return path.normalize(expandedPath); +} catch (err: any) { + // Only fallback for path length related errors + if (err?.code === 'ENAMETOOLONG') { return expandedPath; } - return path.normalize(expandedPath); + throw err; // rethrow other unexpected errors + } } From cec1aa2e907b75cb3fdc0d67ff2fc118fcfd559e Mon Sep 17 00:00:00 2001 From: renuka16032007 Date: Sun, 12 Apr 2026 15:54:08 +0530 Subject: [PATCH 3/4] "docs: remove redundant comments" --- packages/cli/src/utils/resolvePath.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/cli/src/utils/resolvePath.ts b/packages/cli/src/utils/resolvePath.ts index 35dab9fd8e2..581983352c6 100644 --- a/packages/cli/src/utils/resolvePath.ts +++ b/packages/cli/src/utils/resolvePath.ts @@ -17,14 +17,13 @@ export function resolvePath(p: string): string { } else if (p === '~' || p.startsWith('~/')) { expandedPath = homedir() + p.substring(1); } - try { - return path.normalize(expandedPath); -} catch (err: any) { - // Only fallback for path length related errors - if (err?.code === 'ENAMETOOLONG') { - return expandedPath; - } - throw err; // rethrow other unexpected errors - } + try { + return path.normalize(expandedPath); + } catch (err: any) { + if (err?.code === 'ENAMETOOLONG') { + return expandedPath; + } + throw err; + } } From f714fdc71966aec8e03b4b510ad89e70538c6417 Mon Sep 17 00:00:00 2001 From: renuka16032007 Date: Sun, 12 Apr 2026 16:16:52 +0530 Subject: [PATCH 4/4] Fix error handling for ENAMETOOLONG in resolvePath"docs: remove redundant comments" --- packages/cli/src/utils/resolvePath.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/utils/resolvePath.ts b/packages/cli/src/utils/resolvePath.ts index 581983352c6..c0247fa22d9 100644 --- a/packages/cli/src/utils/resolvePath.ts +++ b/packages/cli/src/utils/resolvePath.ts @@ -20,7 +20,7 @@ export function resolvePath(p: string): string { try { return path.normalize(expandedPath); } catch (err: any) { - if (err?.code === 'ENAMETOOLONG') { + if (err.code === 'ENAMETOOLONG') { return expandedPath; } throw err;