Skip to content

fix: cli proxy config updates#6846

Merged
bijin-bruno merged 2 commits intousebruno:mainfrom
lohit-bruno:cli_proxy_config_updates
Jan 19, 2026
Merged

fix: cli proxy config updates#6846
bijin-bruno merged 2 commits intousebruno:mainfrom
lohit-bruno:cli_proxy_config_updates

Conversation

@lohit-bruno
Copy link
Collaborator

@lohit-bruno lohit-bruno commented Jan 19, 2026

Description

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

    • Unified proxy handling with automatic legacy-format conversion, clearer inherit/disabled semantics, system-proxy fallback, and improved proxy authentication behavior.
    • Proxy normalization is exposed for reuse across the app.
  • Tests

    • Added comprehensive test coverage for proxy transformation, migrations, edge cases, and defaults.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Walkthrough

Centralizes proxy config migration into a new exported transformProxyConfig and updates callers (CLI runner, Electron config) to use it; adds tests for the utility and tweaks proxy selection/auth logic in the CLI runner.

Changes

Cohort / File(s) Summary
Proxy utility (new)
packages/bruno-requests/src/utils/proxy-util.ts
Adds transformProxyConfig() to normalize legacy proxy shapes to the new { inherit?, disabled?, protocol, hostname, port, bypassProxy, auth? } model with defaults and cleanup of false/no-op fields.
Proxy utility tests
packages/bruno-requests/src/utils/proxy-util.spec.ts
Adds comprehensive tests covering migration rules, edge cases (null/undefined, missing fields, SOCKS), and no-op behavior for already-new-format inputs.
Public export
packages/bruno-requests/src/index.ts
Exports transformProxyConfig from the public API.
CLI runner changes
packages/bruno-cli/src/runner/run-single-request.js
Imports transformProxyConfig; normalizes collection proxy config; introduces collectionProxyDisabled, collectionProxyInherit, and collectionProxyConfigData; updates proxy selection flow and inverts proxy auth flag logic to use auth.disabled.
Electron config refactor
packages/bruno-electron/src/utils/transformBrunoConfig.js
Removes inline legacy-proxy migration and delegates to transformProxyConfig(brunoConfig.proxy); removes lodash get usage in that path.

Sequence Diagram(s)

(Skipped — changes are internal refactor and do not introduce multi-component sequential flows warranting a diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

size/XXL

Suggested reviewers

  • helloanoop
  • naman-bruno
  • bijin-bruno

Poem

🔁 Old proxy rules now take a trip,
Transformed and folded into one small script,
Tests sing loud, the CLI nods,
Electron skips the duplicate odds,
Configs align — a tidy ship ⚓️

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change—introducing proxy config transformation logic across the CLI and related packages.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/bruno-cli/src/runner/run-single-request.js (1)

316-327: Avoid sending empty proxy credentials when auth isn’t configured.

With old configs that omit auth, auth.disabled is undefined, so proxyAuthEnabled becomes true and the URI includes empty credentials. This can unintentionally trigger proxy auth with blank values. Gate auth on the presence of credentials (or explicit disablement).

✅ Suggested fix
-        const proxyAuthEnabled = !get(proxyConfig, 'auth.disabled', false);
+        const proxyAuthUsername = interpolateString(get(proxyConfig, 'auth.username', ''), interpolationOptions);
+        const proxyAuthPassword = interpolateString(get(proxyConfig, 'auth.password', ''), interpolationOptions);
+        const hasAuthCredentials = Boolean(proxyAuthUsername || proxyAuthPassword);
+        const proxyAuthEnabled = !get(proxyConfig, 'auth.disabled', false) && hasAuthCredentials;
         const socksEnabled = proxyProtocol.includes('socks');
         let uriPort = isUndefined(proxyPort) || isNull(proxyPort) ? '' : `:${proxyPort}`;
         let proxyUri;
         if (proxyAuthEnabled) {
-          const proxyAuthUsername = encodeURIComponent(interpolateString(get(proxyConfig, 'auth.username'), interpolationOptions));
-          const proxyAuthPassword = encodeURIComponent(interpolateString(get(proxyConfig, 'auth.password'), interpolationOptions));
-
-          proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}${uriPort}`;
+          const encodedUsername = encodeURIComponent(proxyAuthUsername);
+          const encodedPassword = encodeURIComponent(proxyAuthPassword);
+          proxyUri = `${proxyProtocol}://${encodedUsername}:${encodedPassword}@${proxyHostname}${uriPort}`;
         } else {
           proxyUri = `${proxyProtocol}://${proxyHostname}${uriPort}`;
         }

@lohit-bruno lohit-bruno force-pushed the cli_proxy_config_updates branch from 3960757 to 6025bfc Compare January 19, 2026 14:31
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/bruno-cli/src/runner/run-single-request.js`:
- Around line 354-357: The code logs the raw http_proxy value (which may contain
credentials) before setting request.httpAgent; remove the console.log({
http_proxy }) to avoid leaking secrets, or if logging is required use a
sanitized form (e.g., mask credentials) before logging. Update the block that
references http_proxy, new URL(http_proxy), and request.httpAgent = new
HttpProxyAgent(http_proxy) to no longer print the full http_proxy value to
stdout.
🧹 Nitpick comments (1)
packages/bruno-requests/src/utils/proxy-util.ts (1)

40-44: Guard against legacy configs missing enabled.

Migration only runs when enabled exists. If any persisted legacy configs omit enabled, they’ll bypass migration and downstream code will treat old shape as new (e.g., auth.disabled won’t be set). Please verify whether enabled is always present in stored legacy configs; if not, consider broadening old-format detection (e.g., treat configs without config as old).

🔧 Possible adjustment
-export const transformProxyConfig = (proxy: OldProxyConfig | NewProxyConfig | null | undefined): NewProxyConfig | OldProxyConfig => {
+export const transformProxyConfig = (proxy: OldProxyConfig | NewProxyConfig | null | undefined): NewProxyConfig | OldProxyConfig => {
   proxy = proxy || {};
   // Check if this is an old format (has 'enabled' property)
-  if (proxy.hasOwnProperty('enabled')) {
+  const isOldFormat = Object.prototype.hasOwnProperty.call(proxy, 'enabled')
+    || !Object.prototype.hasOwnProperty.call(proxy, 'config');
+  if (isOldFormat) {
     const oldProxy = proxy as OldProxyConfig;
     const enabled = oldProxy.enabled;

@bijin-bruno bijin-bruno merged commit 6642f4d into usebruno:main Jan 19, 2026
8 checks passed
FraCata00 pushed a commit to FraCata00/bruno that referenced this pull request Feb 9, 2026
* fix: cli `proxy config` updates

* fix: review comment fixes
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