Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nemoclaw/src/lib/subprocess-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function withLocalNoProxy(env: Record<string, string>): 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)) {
Expand Down
21 changes: 21 additions & 0 deletions src/lib/subprocess-env.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> = { 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<string, string> = {
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");
});
Comment on lines +44 to +56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Verify no_proxy normalization for consistency.

The test sets both NO_PROXY and no_proxy with malformed input but only verifies NO_PROXY is normalized. For consistency with other tests in this file (lines 58-67, 80-89), also verify no_proxy is normalized correctly.

✅ Add assertions for no_proxy
    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");
+   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");
  });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it("strips empty segments from a NO_PROXY with doubled or trailing commas", () => {
const env: Record<string, string> = {
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("strips empty segments from a NO_PROXY with doubled or trailing commas", () => {
const env: Record<string, string> = {
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");
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");
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/subprocess-env.test.ts` around lines 44 - 56, The test only asserts
normalization for env.NO_PROXY; update the same test ("strips empty segments
from a NO_PROXY with doubled or trailing commas") to also assert env.no_proxy is
normalized the same way—after calling withLocalNoProxy(env) add checks that
env.no_proxy does not contain ",,", does not start or end with a comma
(/^,|,$/), and contains "corp.internal", "other.com", and "localhost", mirroring
the existing expectations for env.NO_PROXY and using the same symbols
(withLocalNoProxy, env.NO_PROXY, env.no_proxy).


it("appends only the missing local entries when NO_PROXY already has localhost", () => {
const env: Record<string, string> = {
HTTP_PROXY: "http://proxy:8888",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/subprocess-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function withLocalNoProxy(env: Record<string, string>): 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)) {
Expand Down
Loading