{"record":{"id":"502e35e46d589fae","repo":"usebruno/bruno","slug":"invalid-system-https-proxy","errorCode":null,"errorMessage":"Invalid system https_proxy","messagePattern":"Invalid system https_proxy","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/utils/http-https-agents.ts","lineNumber":580,"sourceCode":"      const shouldUseSystemProxy = shouldUseProxy(requestUrl, 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            httpAgent = getOrCreateHttpAgent({ AgentClass: HttpProxyAgent, options: systemHttpProxyAgentOptions as any, proxyUri: http_proxy, timeline: timeline || null, disableCache, hostname });\n          }\n        } catch (error) {\n          throw new Error('Invalid system http_proxy');\n        }\n        try {\n          if (https_proxy?.length && isHttpsRequest) {\n            new URL(https_proxy);\n            httpsAgent = getOrCreateHttpsAgent({ AgentClass: PatchedHttpsProxyAgent, options: tlsOptions as any, proxyUri: https_proxy, timeline: timeline || null, disableCache, hostname }) as HttpsAgent;\n          }\n        } catch (error) {\n          throw new Error('Invalid system https_proxy');\n        }\n      }\n    }\n  }\n\n  if (!httpAgent && !httpsAgent) {\n    if (isHttpsRequest) {\n      httpsAgent = getOrCreateHttpsAgent({ AgentClass: https.Agent, options: tlsOptions as any, timeline: timeline || null, disableCache, hostname }) as HttpsAgent;\n    } else {\n      httpAgent = getOrCreateHttpAgent({ AgentClass: http.Agent, options: { keepAlive: true }, timeline: timeline || null, disableCache, hostname });\n    }\n  }\n\n  return { httpAgent, httpsAgent };\n}\n\nconst getHttpHttpsAgents = async ({\n  requestUrl,","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/utils/http-https-agents.ts#L562-L598","documentation":"Thrown by getHttpHttpsAgents when proxyMode is 'system', the request is HTTPS, a non-empty https_proxy value is present, and either new URL(https_proxy) or getOrCreateHttpsAgent(PatchedHttpsProxyAgent, ...) raises. The library refuses to silently fall back to a direct connection because doing so would bypass the user's intended (and now broken) proxy, leaking traffic. The catch discards the original error's specifics, surfacing only this generic message.","triggerScenarios":"An HTTPS request runs with proxyMode 'system'; shouldUseProxy(requestUrl, no_proxy) returns true; https_proxy env/collection value is non-empty but malformed (e.g. 'localhost:3128' with no scheme, 'htps://...', 'ftp://proxy', trailing stray chars), OR it is well-formed but PatchedHttpsProxyAgent construction fails (unsupported scheme, missing host, bad TLS options).","commonSituations":"Corporate proxy env vars copied without an http:// scheme; switching from HTTP to SOCKS proxy (this agent only handles HTTP/HTTPS CONNECT proxies); typo in the collection's system-proxy override; proxy value containing auth with unescaped special characters; recent OS-level proxy change propagated into the systemProxyConfig.","solutions":["Inspect the effective https_proxy value (systemProxyConfig.get('https_proxy')) and confirm it parses: must include a scheme (http:// or https://), a host, and a port, e.g. http://proxy.corp:3128.","If a SOCKS proxy is required, switch the collection's proxy mode to a configured proxy that uses a SOCKS-capable agent rather than 'system'; the HttpsProxyAgent path does not support socks://.","Temporarily set proxyMode to 'off' or a working 'configured' proxy to confirm the https_proxy value is the culprit, then correct it.","Ensure no_proxy still matches the request URL if the target should bypass the proxy entirely."],"exampleFix":"// before\nprocess.env.https_proxy = 'proxy.corp:3128'; // missing scheme -> new URL() throws\n\n// after\nprocess.env.https_proxy = 'http://proxy.corp:3128';","handlingStrategy":"validation","validationCode":"import { URL } from 'node:url';\nfunction assertValidProxy(value, label) {\n  if (!value) return; // empty is allowed (means 'no proxy')\n  let u;\n  try { u = new URL(value); } catch { throw new Error(`${label} is not a valid URL: ${value}`); }\n  if (!['http:', 'https:'].includes(u.protocol)) {\n    throw new Error(`${label} must be http(s):// scheme, got ${u.protocol}`);\n  }\n  if (!u.hostname) throw new Error(`${label} is missing a host`);\n}\n// run before issuing requests\nassertValidProxy(systemProxyConfig.get('https_proxy'), 'https_proxy');\nassertValidProxy(systemProxyConfig.get('http_proxy'), 'http_proxy');","typeGuard":"import { URL } from 'node:url';\nfunction isValidProxyUrl(v) {\n  if (typeof v !== 'string' || v.length === 0) return false;\n  try {\n    const u = new URL(v);\n    return ['http:', 'https:'].includes(u.protocol) && !!u.hostname;\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  const { httpAgent, httpsAgent } = await getHttpHttpsAgents(opts);\n} catch (e) {\n  if (/Invalid system https?_proxy/.test(e?.message)) {\n    // surface a precise, actionable message to the user; do not silently fall back\n    throw new Error('Configured proxy is invalid. Fix or disable it. Cause: ' + e.message);\n  }\n  throw e;\n}","preventionTips":["Validate proxy URLs once at config/collection load and reject invalid values early.","Never propagate socks:// or ftp:// values into 'system' proxy mode; route SOCKS through a configured SOCKS agent.","Log the proxy scheme at startup so misconfigurations are obvious in support tickets.","Treat the absence of a scheme as an error, not a default-to-http convenience."],"tags":["network","proxy","configuration","env-vars","https"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}