Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(server): detect localized Windows command errors (#2152)
Raul Pereira da Silvab0b7b38da1dc
diff --git a/apps/server/src/processRunner.test.ts b/apps/server/src/processRunner.test.tsindex 15ad4daf0..af4ff528e 100644--- a/apps/server/src/processRunner.test.ts+++ b/apps/server/src/processRunner.test.ts@@ -1,6 +1,6 @@import { describe, expect, it } from "vitest";-import { runProcess } from "./processRunner.ts";+import { isWindowsCommandNotFound, runProcess } from "./processRunner.ts";describe("runProcess", () => {it("fails when output exceeds max buffer in default mode", async () => {@@ -21,3 +21,21 @@ describe("runProcess", () => {expect(result.stderrTruncated).toBe(false);});});++describe("isWindowsCommandNotFound", () => {+ it("matches the localized German cmd.exe error text", () => {+ const originalPlatform = process.platform;+ Object.defineProperty(process, "platform", { value: "win32", configurable: true });++ try {+ expect(+ isWindowsCommandNotFound(+ 1,+ "wird nicht als interner oder externer Befehl, betriebsfahiges Programm oder Batch-Datei erkannt",+ ),+ ).toBe(true);+ } finally {+ Object.defineProperty(process, "platform", { value: originalPlatform, configurable: true });+ }+ });+});diff --git a/apps/server/src/processRunner.ts b/apps/server/src/processRunner.tsindex 540261288..03b164fc2 100644--- a/apps/server/src/processRunner.ts+++ b/apps/server/src/processRunner.ts@@ -37,10 +37,23 @@ function normalizeSpawnError(command: string, args: readonly string[], error: unreturn new Error(`Failed to run ${commandLabel(command, args)}: ${error.message}`);}+const WINDOWS_COMMAND_NOT_FOUND_PATTERNS = [+ /is not recognized as an internal or external command/i,+ /n.o . reconhecido como um comando interno/i,+ /non . riconosciuto come comando interno o esterno/i,+ /n.est pas reconnu en tant que commande interne/i,+ /no se reconoce como un comando interno o externo/i,+ /wird nicht als interner oder externer befehl/i,+] as const;++function hasWindowsCommandNotFoundMessage(output: string): boolean {+ return WINDOWS_COMMAND_NOT_FOUND_PATTERNS.some((pattern) => pattern.test(output));+}+export function isWindowsCommandNotFound(code: number | null, stderr: string): boolean {if (process.platform !== "win32") return false;if (code === 9009) return true;- return /is not recognized as an internal or external command/i.test(stderr);+ return hasWindowsCommandNotFoundMessage(stderr);}function normalizeExitError(