diff --git a/nemoclaw/src/lib/subprocess-env.ts b/nemoclaw/src/lib/subprocess-env.ts index 211562b0104..a1819ce4292 100644 --- a/nemoclaw/src/lib/subprocess-env.ts +++ b/nemoclaw/src/lib/subprocess-env.ts @@ -60,7 +60,10 @@ export function withLocalNoProxy(env: Record): void { if (!hasProxy) return; for (const key of ["NO_PROXY", "no_proxy"] as const) { const current = env[key] ?? ""; - const parts = current ? current.split(",").map((s) => s.trim()) : []; + const parts = current + .split(",") + .map((s) => s.trim()) + .filter(Boolean); let changed = false; for (const host of ["localhost", "127.0.0.1", "host.docker.internal", "::1", "0.0.0.0"]) { if (!parts.includes(host)) { diff --git a/src/lib/subprocess-env.test.ts b/src/lib/subprocess-env.test.ts index 1121f2522e2..02abf5c65f7 100644 --- a/src/lib/subprocess-env.test.ts +++ b/src/lib/subprocess-env.test.ts @@ -34,6 +34,27 @@ describe("withLocalNoProxy", () => { expect(env.no_proxy).toBe(LOCAL_NO_PROXY); }); + it("adds local host-bound names when lowercase https_proxy is set", () => { + const env: Record = { https_proxy: "http://proxy:8888" }; + withLocalNoProxy(env); + expect(env.NO_PROXY).toBe(LOCAL_NO_PROXY); + expect(env.no_proxy).toBe(LOCAL_NO_PROXY); + }); + + it("strips empty segments from a NO_PROXY with doubled or trailing commas", () => { + const env: Record = { + HTTP_PROXY: "http://proxy:8888", + NO_PROXY: "corp.internal,,other.com,", + no_proxy: "corp.internal,,other.com,", + }; + withLocalNoProxy(env); + expect(env.NO_PROXY).not.toContain(",,"); + expect(env.NO_PROXY).not.toMatch(/^,|,$/); + expect(env.NO_PROXY).toContain("corp.internal"); + expect(env.NO_PROXY).toContain("other.com"); + expect(env.NO_PROXY).toContain("localhost"); + }); + it("appends only the missing local entries when NO_PROXY already has localhost", () => { const env: Record = { HTTP_PROXY: "http://proxy:8888", diff --git a/src/lib/subprocess-env.ts b/src/lib/subprocess-env.ts index 0188983392a..a829a0a66c0 100644 --- a/src/lib/subprocess-env.ts +++ b/src/lib/subprocess-env.ts @@ -60,7 +60,7 @@ export function withLocalNoProxy(env: Record): void { if (!hasProxy) return; for (const key of ["NO_PROXY", "no_proxy"] as const) { const current = env[key] ?? ""; - const parts = current ? current.split(",").map((s) => s.trim()) : []; + const parts = current.split(",").map((s) => s.trim()).filter(Boolean); let changed = false; for (const host of ["localhost", "127.0.0.1", "host.docker.internal", "::1", "0.0.0.0"]) { if (!parts.includes(host)) {