Skip to content

fix: honor OS-level PAC configuration in system proxy mode - #7766

Merged
sid-bruno merged 11 commits into
usebruno:mainfrom
pooja-bruno:fix/system-proxy-honor-os-pac
May 27, 2026
Merged

sid-bruno merged 11 commits into
usebruno:mainfrom
pooja-bruno:fix/system-proxy-honor-os-pac

Conversation

@pooja-bruno

@pooja-bruno pooja-bruno commented Apr 15, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Bruno supports PAC proxy resolution when explicitly configured in preferences, but in System proxy mode, OS-level PAC configuration is silently ignored.

JIRA

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • New Features

    • App detects and honors system PAC (Proxy Auto-Config) URLs on Windows, macOS, and Linux; PACs are used for routing when present.
    • System proxy configuration objects now consistently include a pac_url field (present or null).
    • Preferences UI shows the PAC URL (or "-" when unset).
  • Tests

    • Added integration and fixture tests validating PAC-based proxy behavior, including DIRECT and proxied scenarios.

Review Change Stack

@coderabbitai

coderabbitai Bot commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds end-to-end PAC (Proxy Auto-Config) support: proxy detectors return pac_url, types and agent logic accept and resolve PAC, electron IPC/store fallbacks include pac_url, UI shows it, and unit + macOS integration tests and fixtures validate DIRECT/proxied flows.

Changes

System PAC / Proxy resolution (single cohesive cohort)

Layer / File(s) Summary
ProxyConfiguration shape
packages/bruno-requests/src/network/system-proxy/types.ts, packages/bruno-requests/src/network/system-proxy/index.ts, packages/bruno-requests/src/utils/http-https-agents.ts
Add optional `pac_url?: string
Platform detectors (macOS / Linux / Windows & tests)
packages/bruno-requests/src/network/system-proxy/utils/macos.ts, packages/bruno-requests/src/network/system-proxy/utils/linux.ts, packages/bruno-requests/src/network/system-proxy/utils/windows.ts, packages/bruno-requests/src/network/system-proxy/utils/macos.spec.ts, packages/bruno-requests/src/network/system-proxy/index.spec.js
Detect and surface PAC/autoconfig URLs: macOS reads ProxyAutoConfigURLString when enabled; GNOME/KDE return autoconfig URLs for auto mode; Windows reads AutoConfigURL and returns pac_url (alongside manual proxies when applicable). Unit tests updated to assert pac_url.
PAC resolution and agent selection
packages/bruno-requests/src/utils/http-https-agents.ts
Introduce resolveAgentsFromPac(...) to fetch & evaluate PAC, parse the first directive and produce http/https/socks agents. Refactor explicit pac mode and prefer OS pac_url in system mode; exceptions during PAC resolution fail open (direct).
Electron IPC / cached fallback & proxy-util
packages/bruno-electron/src/ipc/network/cert-utils.js, packages/bruno-electron/src/store/system-proxy.js, packages/bruno-electron/src/utils/proxy-util.js
Ensure cached system-proxy fallback shapes include pac_url: null on cache-miss and add PAC-aware resolution/logging in proxy-util without throwing on failures.
Tests, fixtures, and E2E checks
packages/bruno-requests/src/network/system-proxy/index.spec.js, tests/proxy/system-pac/...
Update unit tests to expect pac_url: null when absent. Add system-PAC Playwright/Electron macOS integration tests, PAC server fixtures, and request collection fixtures asserting DIRECT (no proxy) and proxied flows.
UI rendering
packages/bruno-app/src/components/Preferences/ProxySettings/SystemProxy/index.js
Render pac_url in the SystemProxy preferences panel (shows - when unset).

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant OS as OS Detector
    participant Resolver as PAC Resolver
    participant Agent as HTTP/HTTPS Agent
    participant Server as Target Server

    Client->>OS: request ProxyConfiguration for URL
    OS-->>Client: { http_proxy, https_proxy, no_proxy, pac_url }

    alt pac_url present
        Client->>Resolver: fetch & evaluate PAC for request URL
        Resolver->>Resolver: execute PAC → directive(s)
        alt directive is PROXY / SOCKS
            Resolver-->>Client: return proxy agent
        else directive is DIRECT or no match
            Resolver-->>Client: return direct (no agent)
        end
    else no pac_url
        Client->>Client: apply http_proxy/https_proxy + no_proxy rules
    end

    Client->>Agent: send request via chosen agent
    Agent->>Server: (proxied or direct) request
    Server-->>Agent: response
    Agent-->>Client: response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

PAC whispers rules in JS disguise,
DIRECT or proxy, it maps the skies.
Detectors hand the script with care,
Resolver picks the route to fare—
Requests find their path and fly. 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately reflects the main change: adding OS-level PAC (Proxy Auto-Config) support in system proxy mode.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (4)
packages/bruno-electron/src/utils/proxy-util.js (1)

107-134: Inconsistent agent assignment compared to http-https-agents.ts.

This helper sets both httpAgent and httpsAgent regardless of request protocol, while the equivalent resolveAgentsFromPac in http-https-agents.ts (lines 424-437) selectively sets only the needed agent based on isHttpsRequest. This could cause unnecessary agent creation.

Consider aligning the behavior by passing isHttpsRequest and conditionally setting only the required agent.

♻️ Suggested approach
-async function resolveAgentsFromPac({ pacSource, requestUrl, requestConfig, tlsOptions, httpsAgentRequestFields, timeline, disableCache, hostname }) {
+async function resolveAgentsFromPac({ pacSource, requestUrl, requestConfig, tlsOptions, httpsAgentRequestFields, timeline, disableCache, hostname, isHttpsRequest }) {
   const resolver = await getPacResolver({ pacSource, httpsAgentRequestFields });
   const directives = await resolver.resolve(requestUrl);

   if (!directives || !directives.length) {
     return null;
   }

   const first = directives[0];

   if (/^(PROXY|HTTPS?)\s+/i.test(first)) {
     const parts = first.split(/\s+/);
     const keyword = parts[0].toUpperCase();
     const hostPort = parts[1];
     const scheme = keyword === 'HTTPS' ? 'https' : 'http';
     const proxyUri = `${scheme}://${hostPort}`;
-    requestConfig.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: { keepAlive: true }, proxyUri, timeline, disableCache, hostname });
-    requestConfig.httpsAgent = getOrCreateHttpsAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri, timeline, disableCache, hostname });
+    if (isHttpsRequest) {
+      requestConfig.httpsAgent = getOrCreateHttpsAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri, timeline, disableCache, hostname });
+    } else {
+      requestConfig.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: { keepAlive: true }, proxyUri, timeline, disableCache, hostname });
+    }
   } else if (/^SOCKS/i.test(first)) {
     // ... similar change for SOCKS
   }

   return directives;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-electron/src/utils/proxy-util.js` around lines 107 - 134, The
resolveAgentsFromPac function currently assigns both requestConfig.httpAgent and
requestConfig.httpsAgent unconditionally, creating unnecessary agents; update
resolveAgentsFromPac to accept an isHttpsRequest boolean (like in
http-https-agents.ts) and only call getOrCreateHttpAgent when !isHttpsRequest
and only call getOrCreateHttpsAgent/appropriate Agent when isHttpsRequest,
preserving the existing proxyUri/scheme/proto logic and using the same
AgentClass and options (HttpProxyAgent, PatchedHttpsProxyAgent, SocksProxyAgent)
so you avoid instantiating the unused agent.
packages/bruno-requests/src/network/system-proxy/utils/linux.ts (1)

90-95: Consider adding pac_url: null to manual proxy returns for type consistency.

The PAC code paths return { pac_url, ... } but the manual proxy returns here (and in getKDEProxy, parseProxyFromContent) omit pac_url. This inconsistency may cause downstream code to handle undefined vs null differently.

♻️ Suggested fix
       return {
         http_proxy,
         https_proxy,
         no_proxy: normalizeNoProxy(rawNoProxy),
+        pac_url: null,
         source: 'linux-system'
       };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-requests/src/network/system-proxy/utils/linux.ts` around lines
90 - 95, The manual proxy return objects lack a pac_url field causing type
inconsistency; update the manual-return branches in the linux-system code (the
return currently including http_proxy, https_proxy, no_proxy, source:
'linux-system') as well as corresponding manual-return spots in getKDEProxy and
parseProxyFromContent to include pac_url: null so all proxy result objects
always have a pac_url property (PAC code paths should continue to return the
actual pac_url).
packages/bruno-requests/src/network/system-proxy/utils/windows.ts (1)

220-226: Consider adding pac_url: null for consistency with the PAC code path.

Same observation as the Linux file: parseProxyString returns a ProxyConfiguration without pac_url, creating a shape inconsistency with configurations that include it.

♻️ Suggested fix
     return {
       http_proxy,
       https_proxy,
       no_proxy: bypassList && bypassList !== '(none)' ? normalizeNoProxy(bypassList) : null,
+      pac_url: null,
       source: 'windows-system'
     };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/bruno-requests/src/network/system-proxy/utils/windows.ts` around
lines 220 - 226, The returned ProxyConfiguration from the Windows system parser
(the object returned in the function that uses http_proxy, https_proxy and
normalizeNoProxy) is missing pac_url which causes shape inconsistency with the
PAC code path; update the returned object in the Windows parser (the same place
parseProxyString/normalizeNoProxy are used) to include pac_url: null so
ProxyConfiguration always has pac_url present.
tests/proxy/system-pac/system-pac-proxy.spec.ts (1)

25-35: Consider try/finally pattern for system state cleanup.

If startServers() succeeds but a test fails mid-execution, disableSystemPac() still runs via afterAll. However, if enableSystemPac() throws (e.g., permission denied), the system may be left in an inconsistent state. Consider wrapping enableSystemPac calls with their own error handling.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/proxy/system-pac/system-pac-proxy.spec.ts` around lines 25 - 35, The
before/after hooks should ensure enableSystemPac failures can't leave the OS
proxy set; wrap calls to enableSystemPac (and any system-modifying setup) in a
try/finally so disableSystemPac always runs on error: modify the setup where
startServers() and enableSystemPac() are invoked (referencing startServers,
enableSystemPac, disableSystemPac, stopServers) to catch exceptions from
enableSystemPac and call disableSystemPac in a finally block, and ensure
stopServers is awaited in the cleanup path as well so servers are stopped
whether setup succeeds or fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-requests/src/network/system-proxy/utils/macos.spec.ts`:
- Around line 48-49: Add a positive PAC-enabled test in macos.spec.ts that
exercises the new PAC extraction path: create a test case that stubs/mocks the
macOS system proxy output to include a PAC URL and assert that the parsed result
(the object under test that currently exposes pac_url) returns that non-null URL
(not null) and retains source: 'macos-system'; locate the spec in
packages/bruno-requests/src/network/system-proxy/utils/macos.spec.ts and add the
test alongside the existing cases that currently assert pac_url: null so it
covers the PAC-enabled branch of the parsing function that produces pac_url.

In `@tests/proxy/system-pac/system-pac-proxy.spec.ts`:
- Around line 12-20: The test hardcodes NETWORK_SERVICE = 'Wi-Fi' and calls
macOS-only networksetup without platform guarding; update the test to first skip
on non-Darwin platforms (use a platform check and test.skip) and make
NETWORK_SERVICE dynamic by detecting an active service or accepting the service
name from environment/utility instead of hardcoding; locate the NETWORK_SERVICE
constant and the helper functions enableSystemPac and disableSystemPac and
change them to either query available services (e.g., via networksetup
-listallnetworkservices) or accept a resolved service name, and ensure the
entire test is wrapped with a Darwin-only guard so networksetup is never invoked
on other OSes.

---

Nitpick comments:
In `@packages/bruno-electron/src/utils/proxy-util.js`:
- Around line 107-134: The resolveAgentsFromPac function currently assigns both
requestConfig.httpAgent and requestConfig.httpsAgent unconditionally, creating
unnecessary agents; update resolveAgentsFromPac to accept an isHttpsRequest
boolean (like in http-https-agents.ts) and only call getOrCreateHttpAgent when
!isHttpsRequest and only call getOrCreateHttpsAgent/appropriate Agent when
isHttpsRequest, preserving the existing proxyUri/scheme/proto logic and using
the same AgentClass and options (HttpProxyAgent, PatchedHttpsProxyAgent,
SocksProxyAgent) so you avoid instantiating the unused agent.

In `@packages/bruno-requests/src/network/system-proxy/utils/linux.ts`:
- Around line 90-95: The manual proxy return objects lack a pac_url field
causing type inconsistency; update the manual-return branches in the
linux-system code (the return currently including http_proxy, https_proxy,
no_proxy, source: 'linux-system') as well as corresponding manual-return spots
in getKDEProxy and parseProxyFromContent to include pac_url: null so all proxy
result objects always have a pac_url property (PAC code paths should continue to
return the actual pac_url).

In `@packages/bruno-requests/src/network/system-proxy/utils/windows.ts`:
- Around line 220-226: The returned ProxyConfiguration from the Windows system
parser (the object returned in the function that uses http_proxy, https_proxy
and normalizeNoProxy) is missing pac_url which causes shape inconsistency with
the PAC code path; update the returned object in the Windows parser (the same
place parseProxyString/normalizeNoProxy are used) to include pac_url: null so
ProxyConfiguration always has pac_url present.

In `@tests/proxy/system-pac/system-pac-proxy.spec.ts`:
- Around line 25-35: The before/after hooks should ensure enableSystemPac
failures can't leave the OS proxy set; wrap calls to enableSystemPac (and any
system-modifying setup) in a try/finally so disableSystemPac always runs on
error: modify the setup where startServers() and enableSystemPac() are invoked
(referencing startServers, enableSystemPac, disableSystemPac, stopServers) to
catch exceptions from enableSystemPac and call disableSystemPac in a finally
block, and ensure stopServers is awaited in the cleanup path as well so servers
are stopped whether setup succeeds or fails.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a06975e5-0a99-46af-8e95-afd91be54a47

📥 Commits

Reviewing files that changed from the base of the PR and between b733d0e and b0005ef.

📒 Files selected for processing (16)
  • packages/bruno-electron/src/ipc/network/cert-utils.js
  • packages/bruno-electron/src/store/system-proxy.js
  • packages/bruno-electron/src/utils/proxy-util.js
  • packages/bruno-requests/src/network/system-proxy/index.spec.js
  • packages/bruno-requests/src/network/system-proxy/index.ts
  • packages/bruno-requests/src/network/system-proxy/types.ts
  • packages/bruno-requests/src/network/system-proxy/utils/linux.ts
  • packages/bruno-requests/src/network/system-proxy/utils/macos.spec.ts
  • packages/bruno-requests/src/network/system-proxy/utils/macos.ts
  • packages/bruno-requests/src/network/system-proxy/utils/windows.ts
  • packages/bruno-requests/src/utils/http-https-agents.ts
  • tests/proxy/system-pac/fixtures/collection/bruno.json
  • tests/proxy/system-pac/fixtures/collection/direct.bru
  • tests/proxy/system-pac/fixtures/collection/proxied.bru
  • tests/proxy/system-pac/init-user-data/preferences.json
  • tests/proxy/system-pac/system-pac-proxy.spec.ts

@pooja-bruno
pooja-bruno marked this pull request as draft April 15, 2026 10:00
@pooja-bruno
pooja-bruno marked this pull request as ready for review April 30, 2026 10:24

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tests/proxy/system-pac/system-pac-proxy.spec.ts (1)

12-16: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Avoid hardcoding the macOS network service name.

Line 12 assumes 'Wi-Fi', which is brittle on hosts where the active service is named differently (e.g., Ethernet/Thunderbolt/custom labels). Prefer an env-configurable service name (or runtime detection) before invoking networksetup.

Suggested patch
-const NETWORK_SERVICE = 'Wi-Fi';
+const NETWORK_SERVICE = process.env.BRUNO_TEST_NETWORK_SERVICE || 'Wi-Fi';
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/proxy/system-pac/system-pac-proxy.spec.ts` around lines 12 - 16, The
test currently hardcodes the macOS network service name via the NETWORK_SERVICE
constant and uses it in enableSystemPac(pacUrl), which breaks on machines where
the active service is named differently; change this to read the service name
from an environment variable (e.g., process.env.SYSTEM_PAC_NETWORK_SERVICE) with
a sensible fallback (or implement runtime detection of the active network
service) and use that value inside enableSystemPac; update references to
NETWORK_SERVICE and ensure tests can override the env var to target different
service names.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/proxy/system-pac/system-pac-proxy.spec.ts`:
- Around line 31-36: The teardown currently calls disableSystemPac() then awaits
stopServers(servers), but if disableSystemPac() throws the servers shutdown is
skipped; update the test.afterAll block (in system-pac-proxy.spec.ts) to ensure
stopServers always runs by wrapping the PAC reset in try/finally (e.g., await
disableSystemPac() inside try and in finally check/await stopServers(servers));
keep the function async and preserve existing null/undefined guard for servers.

---

Duplicate comments:
In `@tests/proxy/system-pac/system-pac-proxy.spec.ts`:
- Around line 12-16: The test currently hardcodes the macOS network service name
via the NETWORK_SERVICE constant and uses it in enableSystemPac(pacUrl), which
breaks on machines where the active service is named differently; change this to
read the service name from an environment variable (e.g.,
process.env.SYSTEM_PAC_NETWORK_SERVICE) with a sensible fallback (or implement
runtime detection of the active network service) and use that value inside
enableSystemPac; update references to NETWORK_SERVICE and ensure tests can
override the env var to target different service names.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d9c025ba-db71-4a92-8bec-d99acc8417ab

📥 Commits

Reviewing files that changed from the base of the PR and between b0005ef and 0ae7ee4.

📒 Files selected for processing (2)
  • packages/bruno-requests/src/network/system-proxy/utils/macos.spec.ts
  • tests/proxy/system-pac/system-pac-proxy.spec.ts

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

♻️ Duplicate comments (1)
tests/proxy/system-pac/system-pac-proxy.spec.ts (1)

12-16: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Hardcoded NETWORK_SERVICE makes this macOS test environment-dependent

Line 12 assumes the service is always Wi-Fi; this fails on hosts using different service names (e.g., Ethernet-only setups). Please resolve the service dynamically or allow explicit override via env var.

Suggested patch
-const NETWORK_SERVICE = 'Wi-Fi';
+function resolveNetworkService() {
+  const fromEnv = process.env.BRUNO_NETWORK_SERVICE;
+  if (fromEnv) {
+    return fromEnv;
+  }
+  const output = execSync('networksetup -listallnetworkservices', { encoding: 'utf8' });
+  const services = output
+    .split('\n')
+    .map((line) => line.trim())
+    .filter((line) => line.length > 0 && !line.startsWith('*'));
+  if (services.includes('Wi-Fi')) {
+    return 'Wi-Fi';
+  }
+  return services[0] || 'Wi-Fi';
+}
+
+const NETWORK_SERVICE = resolveNetworkService();

Based on learnings: “Ensure tests are deterministic and reproducible. No randomness, timing dependencies, or environment-specific assumptions without explicit control.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/proxy/system-pac/system-pac-proxy.spec.ts` around lines 12 - 16, The
test hardcodes NETWORK_SERVICE = 'Wi-Fi' used by enableSystemPac(pacUrl) which
breaks on machines with different network service names; update enableSystemPac
to first check an override env var (e.g., PROCESS_ENV_NETWORK_SERVICE) and if
not present, discover the active macOS network service dynamically (e.g., parse
output of networksetup -listallnetworkservices or system_profiler commands) and
fall back to a safe default, then call execSync with the resolved service name;
ensure the symbol NETWORK_SERVICE is replaced by this resolved value and add a
clear error message if no service can be detected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/proxy/system-pac/system-pac-proxy.spec.ts`:
- Around line 18-20: The teardown currently forces PAC off via
disableSystemPac(), which overwrites existing host proxy settings; modify the
test to read and store the original PAC state and PAC URL at setup (e.g., in
beforeAll), and in afterAll restore the saved values instead of always turning
PAC off—use the same helper functions (disableSystemPac) or add a
restoreSystemPac(originalState, originalUrl) helper to reapply the previous
on/off state and URL; update any other places noted (lines ~31-39) that mutate
PAC so they also save the original state before changing it and restore it in
teardown.

---

Duplicate comments:
In `@tests/proxy/system-pac/system-pac-proxy.spec.ts`:
- Around line 12-16: The test hardcodes NETWORK_SERVICE = 'Wi-Fi' used by
enableSystemPac(pacUrl) which breaks on machines with different network service
names; update enableSystemPac to first check an override env var (e.g.,
PROCESS_ENV_NETWORK_SERVICE) and if not present, discover the active macOS
network service dynamically (e.g., parse output of networksetup
-listallnetworkservices or system_profiler commands) and fall back to a safe
default, then call execSync with the resolved service name; ensure the symbol
NETWORK_SERVICE is replaced by this resolved value and add a clear error message
if no service can be detected.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 656842da-3471-41da-b9a8-b949090cc651

📥 Commits

Reviewing files that changed from the base of the PR and between 0ae7ee4 and c733655.

📒 Files selected for processing (1)
  • tests/proxy/system-pac/system-pac-proxy.spec.ts

@pooja-bruno
pooja-bruno force-pushed the fix/system-proxy-honor-os-pac branch from b790838 to f8e436b Compare May 13, 2026 13:01

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🤖 Prompt for all review comments with 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.

Inline comments:
In `@packages/bruno-electron/src/utils/proxy-util.js`:
- Around line 121-124: The PAC branch builds requestConfig.httpAgent for HTTPS
proxy but omits TLS options; update the call that creates the httpAgent (where
scheme, proxyUri and getOrCreateHttpAgent/HttpProxyAgent are used) to include
tlsOptions (CA, cert/key, rejectUnauthorized, etc.) the same way the manual
proxy path does—i.e., pass tlsOptions into the options for getOrCreateHttpAgent
when scheme === 'https' so proxy certificate validation and client certs are
applied; leave the httpsAgent creation
(getOrCreateHttpsAgent/PatchedHttpsProxyAgent) unchanged.

In `@tests/proxy/system-pac/system-pac-proxy.spec.ts`:
- Around line 14-19: The tests use execSync with shell-interpolated commands in
enableSystemPac and disableSystemPac; replace those with execFileSync calls and
pass the program ("networksetup") and an arguments array instead of a shell
string to avoid interpolation issues—e.g., in enableSystemPac call
execFileSync("networksetup", ["-setautoproxyurl", NETWORK_SERVICE, pacUrl"]) and
in disableSystemPac call execFileSync("networksetup", ["-setautoproxystate",
NETWORK_SERVICE, "off"]) so NETWORK_SERVICE and pacUrl are passed as separate
args.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3cb960a5-178f-4c08-b62e-0fded91ead73

📥 Commits

Reviewing files that changed from the base of the PR and between b790838 and f8e436b.

📒 Files selected for processing (17)
  • packages/bruno-app/src/components/Preferences/ProxySettings/SystemProxy/index.js
  • packages/bruno-electron/src/ipc/network/cert-utils.js
  • packages/bruno-electron/src/store/system-proxy.js
  • packages/bruno-electron/src/utils/proxy-util.js
  • packages/bruno-requests/src/network/system-proxy/index.spec.js
  • packages/bruno-requests/src/network/system-proxy/index.ts
  • packages/bruno-requests/src/network/system-proxy/types.ts
  • packages/bruno-requests/src/network/system-proxy/utils/linux.ts
  • packages/bruno-requests/src/network/system-proxy/utils/macos.spec.ts
  • packages/bruno-requests/src/network/system-proxy/utils/macos.ts
  • packages/bruno-requests/src/network/system-proxy/utils/windows.ts
  • packages/bruno-requests/src/utils/http-https-agents.ts
  • tests/proxy/system-pac/fixtures/collection/bruno.json
  • tests/proxy/system-pac/fixtures/collection/direct.bru
  • tests/proxy/system-pac/fixtures/collection/proxied.bru
  • tests/proxy/system-pac/init-user-data/preferences.json
  • tests/proxy/system-pac/system-pac-proxy.spec.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/bruno-requests/src/network/system-proxy/types.ts
  • tests/proxy/system-pac/init-user-data/preferences.json
  • tests/proxy/system-pac/fixtures/collection/bruno.json
🚧 Files skipped from review as they are similar to previous changes (12)
  • packages/bruno-electron/src/store/system-proxy.js
  • packages/bruno-requests/src/network/system-proxy/index.spec.js
  • packages/bruno-requests/src/network/system-proxy/utils/macos.ts
  • packages/bruno-electron/src/ipc/network/cert-utils.js
  • tests/proxy/system-pac/fixtures/collection/proxied.bru
  • packages/bruno-requests/src/network/system-proxy/index.ts
  • packages/bruno-app/src/components/Preferences/ProxySettings/SystemProxy/index.js
  • packages/bruno-requests/src/network/system-proxy/utils/linux.ts
  • tests/proxy/system-pac/fixtures/collection/direct.bru
  • packages/bruno-requests/src/network/system-proxy/utils/macos.spec.ts
  • packages/bruno-requests/src/network/system-proxy/utils/windows.ts
  • packages/bruno-requests/src/utils/http-https-agents.ts

Comment thread .github/workflows/tests-linux.yml Resolved
sid-bruno
sid-bruno previously approved these changes May 18, 2026
@sid-bruno

Copy link
Copy Markdown
Collaborator

A nit for another ticket
#7766 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants