{"record":{"id":"0dc05274c7ee830a","repo":"nodejs/node","slug":"und-err-invalid-arg-0dc052","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"Proxy URL is mandatory","messagePattern":"Proxy URL is mandatory","errorType":"validation","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/dispatcher/proxy-agent.js","lineNumber":50,"sourceCode":"\nfunction defaultAgentFactory (origin, opts) {\n  if (opts.connections === 1) {\n    return new Client(origin, opts)\n  }\n  return new Pool(origin, opts)\n}\n\nfunction shouldProxyTunnel (requestProtocol, proxyTunnel) {\n  return proxyTunnel === true || requestProtocol !== 'http:'\n}\n\nclass Http1ProxyWrapper extends DispatcherBase {\n  #client\n  #proxyServername\n\n  constructor (proxyUrl, { headers = {}, connect, factory, proxyServername }) {\n    if (!proxyUrl) {\n      throw new InvalidArgumentError('Proxy URL is mandatory')\n    }\n\n    super()\n\n    this[kProxyHeaders] = headers\n    this.#proxyServername = proxyServername\n    if (factory) {\n      this.#client = factory(proxyUrl, { connect })\n    } else {\n      this.#client = new Client(proxyUrl, { connect })\n    }\n  }\n\n  [kDispatch] (opts, handler) {\n    const onResponseStart = handler.onResponseStart\n    handler.onResponseStart = function (controller, statusCode, data, statusMessage) {\n      if (statusCode === 407) {\n        if (typeof handler.onResponseError === 'function') {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/dispatcher/proxy-agent.js#L32-L68","documentation":"Thrown by Http1ProxyWrapper's constructor (inside proxy-agent.js) when proxyUrl is falsy. Http1ProxyWrapper wraps a single upstream Client pointed at a proxy; without a proxy URL it has nothing to connect to, so it rejects before building the underlying Client.","triggerScenarios":"Constructing Http1ProxyWrapper(undefined) or Http1ProxyWrapper(''), or passing an opts object whose proxy URL field resolved to undefined. Http1ProxyWrapper is typically created internally by ProxyAgent when proxyTunnel is false, fed by ProxyAgent.#getUrl(opts).","commonSituations":"Env var HTTP_PROXY/HTTPS_PROXY unset but the code always constructs the wrapper; misrouted config where opts.uri is read under a different key; conditional proxy logic that builds the wrapper even in the no-proxy branch.","solutions":["Provide a non-empty proxy URL string or URL object to Http1ProxyWrapper.","Gate wrapper construction on the presence of a proxy URL so the no-proxy path skips it.","Read the proxy URL from a normalized config helper that errors clearly when it is missing.","Prefer the higher-level ProxyAgent API, which gives a clearer 'Proxy uri is mandatory' message."],"exampleFix":"// before\nnew Http1ProxyWrapper(process.env.MY_PROXY) // undefined when unset\n// after\nconst p = process.env.MY_PROXY\nif (p) new Http1ProxyWrapper(p)","handlingStrategy":"validation","validationCode":"if (!proxyUrl) {\n  throw new Error('A proxy URL is required to build Http1ProxyWrapper')\n}\nnew Http1ProxyWrapper(proxyUrl, opts)","typeGuard":"function isNonEmptyUrl(u) { return u != null && u !== '' }","tryCatchPattern":null,"preventionTips":["Gate proxy construction on the presence of the proxy URL.","Prefer the higher-level ProxyAgent API for clearer errors.","Read proxy URLs through a single normalized config helper."],"tags":["undici","proxy","http-proxy","invalid-arg"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}