{"record":{"id":"a3aafea21e14659c","repo":"usebruno/bruno","slug":"invalid-system-http-proxy","errorCode":null,"errorMessage":"Invalid system http_proxy","messagePattern":"Invalid system http_proxy","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-requests/src/utils/http-https-agents.ts","lineNumber":572,"sourceCode":"    if (pac_url && requestUrl) {\n      try {\n        const result = await resolveAgentsFromPac({ pacSource: pac_url, requestUrl, requestProtocol: isHttpsRequest ? 'https' : 'http', tlsOptions, timeline, disableCache, hostname });\n        if (result.httpAgent) httpAgent = result.httpAgent;\n        if (result.httpsAgent) httpsAgent = result.httpsAgent;\n      } catch {\n      }\n    } else {\n      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 });","sourceCodeStart":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-requests/src/utils/http-https-agents.ts#L554-L590","documentation":"In system-proxy mode for a plain-HTTP request, the loader constructs `new URL(http_proxy)` from the detected system proxy. If the value is not a valid absolute URL, the URL constructor throws and is rewrapped as 'Invalid system http_proxy'.","triggerScenarios":"proxyMode='system', the OS-reported http_proxy is non-empty but malformed (missing scheme, stray characters, bare hostname without protocol), and the request is HTTP (not HTTPS).","commonSituations":"Environment/export http_proxy='proxy.corp:8080' (no scheme); gsettings stored host without protocol; copy-paste introduced whitespace or a leading space; URL contains illegal characters.","solutions":["Set http_proxy with a full scheme: export http_proxy='http://proxy.corp:8080'.","In GNOME: gsettings set org.gnome.system.proxy mode manual and set host/port so the resolver emits a complete URL.","Strip whitespace and verify with `new URL(value)` in a REPL before relying on it."],"exampleFix":"// before\nprocess.env.http_proxy = 'proxy.corp:8080'; // new URL throws -> 'Invalid system http_proxy'\n\n// after\nprocess.env.http_proxy = 'http://proxy.corp:8080';","handlingStrategy":"validation","validationCode":"function ensureValidProxyUrl(value, label) {\n  if (!value) return;\n  let u; try { u = new URL(value); } catch { throw new Error(`Invalid system ${label}`); }\n  if (!u.protocol || !u.hostname) throw new Error(`Invalid system ${label}`);\n}\nensureValidProxyUrl(http_proxy, 'http_proxy');\nensureValidProxyUrl(https_proxy, 'https_proxy');","typeGuard":"function isAbsoluteProxyUrl(v): v is string { try { const u = new URL(v); return !!u.protocol && !!u.hostname; } catch { return false; } }","tryCatchPattern":"try { const agent = buildSystemHttpAgent(http_proxy); } catch (e) { if (/Invalid system http_proxy/.test(e.message)) { /* fall back to direct connection */ } else throw e; }","preventionTips":["Always set http_proxy/https_proxy with a full scheme (http://, https://, socks5://).","Strip whitespace from proxy env vars before parsing.","Test the value with `new URL(...)` in a REPL before relying on it."],"tags":["proxy","system-proxy","url","validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}