{"record":{"id":"4698ffb2bcd37575","repo":"usebruno/bruno","slug":"invalid-system-http-proxy-http-proxy-error","errorCode":null,"errorMessage":"Invalid system http_proxy \"${http_proxy}\": ${error.message}","messagePattern":"Invalid system http_proxy \"(.+?)\": (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/utils/proxy-util.js","lineNumber":191,"sourceCode":"    } else {\n      const shouldUseSystemProxy = shouldUseProxy(requestConfig.url, no_proxy || '');\n      if (shouldUseSystemProxy) {\n        try {\n          if (http_proxy?.length && !isHttpsRequest) {\n            const parsedHttpProxy = new URL(http_proxy);\n            const isHttpsSystemProxy = parsedHttpProxy.protocol === 'https:';\n            const systemHttpProxyAgentOptions = isHttpsSystemProxy ? { keepAlive: true, ...tlsOptions } : { keepAlive: true };\n            if (timeline) {\n              timeline.push({\n                timestamp: new Date(),\n                type: 'info',\n                message: `Using system proxy: ${http_proxy}`\n              });\n            }\n            requestConfig.httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: systemHttpProxyAgentOptions, proxyUri: http_proxy, timeline, disableCache, hostname });\n          }\n        } catch (error) {\n          throw new Error(`Invalid system http_proxy \"${http_proxy}\": ${error.message}`);\n        }\n        try {\n          if (https_proxy?.length && isHttpsRequest) {\n            new URL(https_proxy);\n            if (timeline) {\n              timeline.push({\n                timestamp: new Date(),\n                type: 'info',\n                message: `Using system proxy: ${https_proxy}`\n              });\n            }\n            requestConfig.httpsAgent = getOrCreateHttpsAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions, proxyUri: https_proxy, timeline, disableCache, hostname });\n          }\n        } catch (error) {\n          throw new Error(`Invalid system https_proxy \"${https_proxy}\": ${error.message}`);\n        }\n      }\n    }","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/utils/proxy-util.js#L173-L209","documentation":"Thrown when Bruno runs in `proxyMode === 'system'` (no PAC URL) and the configured `http_proxy` value cannot be parsed or turned into an agent for a plaintext-HTTP request. The guard wraps `new URL(http_proxy)` plus `getOrCreateHttpAgent(...)`; any exception from either is rethrown with this message. It is an environment-validation error: Bruno refuses to silently ship traffic through an unparseable proxy.","triggerScenarios":"Calling a request where `isHttpsRequest === false` while `proxyConfig.http_proxy` (from system/env) is a non-empty string, `pac_url` is absent, `shouldUseProxy(url, no_proxy)` returns true, and `http_proxy` fails `new URL()` (e.g. `proxy.local:8080`) or `getOrCreateHttpAgent` rejects it.","commonSituations":"Shell-exported `http_proxy` missing the `http://`/`https://` scheme; an unexpanded `${VAR}` literal left in the value; trailing whitespace or a stray port; a corporate proxy string pasted from docs with a typo; a port-only or host-only string.","solutions":["Set the full scheme on the proxy, e.g. `http_proxy=http://proxy.local:8080` (or `https://` if the proxy itself is TLS).","Verify the value is not an unexpanded variable: print it and ensure no literal `${...}` remains.","If no proxy is needed, unset `http_proxy` for the Bruno process or add the target host to `no_proxy`.","Restart Bruno after editing the env var so the electron process re-reads it."],"exampleFix":"// before\nexport http_proxy=proxy.local:8080   // missing scheme -> new URL() throws\n\n// after\nexport http_proxy=http://proxy.local:8080","handlingStrategy":"validation","validationCode":"function isValidProxyUrl(value) {\n  if (typeof value !== 'string' || value.trim() === '') return false;\n  try { new URL(value.trim()); return true; } catch { return false; }\n}\n// before configuring system proxy\nif (http_proxy && !isValidProxyUrl(http_proxy)) {\n  throw new Error(`Refusing to start: http_proxy is malformed: ${http_proxy}`);\n}","typeGuard":"function isProxyUrl(value: unknown): value is string {\n  if (typeof value !== 'string' || value.trim() === '') return false;\n  try { new URL(value.trim()); return true; } catch { return false; }\n}","tryCatchPattern":"try {\n  // configure agent\n} catch (error) {\n  if (/Invalid system http_proxy/.test(error.message)) {\n    // surface a 'fix your proxy env' message and fall back to direct\n  } else throw error;\n}","preventionTips":["Validate proxy URLs at app startup, not on the first request.","Always include the scheme (http:// or https://) on proxy env vars.","Log the resolved proxy value (host only) when proxyMode is 'system' to catch unexpanded ${VAR}."],"tags":["network","proxy","config","electron"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}