{"record":{"id":"66a7f07f0874e869","repo":"google-gemini/gemini-cli","slug":"security-initialization-failed-undici-buildconnector-is-not","errorCode":null,"errorMessage":"Security initialization failed: undici.buildConnector is not available.","messagePattern":"Security initialization failed: undici\\.buildConnector is not available\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/utils/fetch.ts","lineNumber":200,"sourceCode":"    if (net.isIP(sanitized) && isAddressPrivate(sanitized)) {\n      callback(\n        new PrivateIpError(`Access to private IP ${sanitized} is blocked`),\n        null,\n      );\n      return;\n    }\n\n    defaultConnector(opts, callback);\n  };\n}\n\nexport function createSafeAgent(options?: {\n  headersTimeout?: number;\n  bodyTimeout?: number;\n}): undici.Agent {\n  const buildConnectorFn = getBuildConnector();\n  if (!buildConnectorFn) {\n    throw new Error(\n      'Security initialization failed: undici.buildConnector is not available.',\n    );\n  }\n\n  const connect = createSafeConnector();\n  return new undici.Agent({\n    headersTimeout: options?.headersTimeout ?? defaultHeadersTimeout,\n    bodyTimeout: options?.bodyTimeout ?? defaultBodyTimeout,\n    connect,\n  });\n}\n\nlet defaultSafeAgent = createSafeAgent();\n\n// Configure default global dispatcher with higher timeouts\nundici.setGlobalDispatcher(\n  new undici.Agent({\n    headersTimeout: defaultHeadersTimeout,","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/6a466a7e2fe2b1255752c1e74f69b31f0216084d/packages/core/src/utils/fetch.ts#L182-L218","documentation":"createSafeAgent failed during security initialization because undici's buildConnector export was not found on the installed undici version. This is a compatibility/API-availability guard: the SSRF-safe HTTP agent cannot be constructed without a custom connector, so construction aborts immediately rather than falling back to an unsafe default connector.","triggerScenarios":"Thrown at packages/core/src/utils/fetch.ts:200 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Upgrade or pin undici to a version that exports buildConnector","Verify no bundler/polyfill is stripping undici internals at build time","Check for duplicate undici installs in node_modules causing the wrong copy to resolve"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6a466a7e2fe2b1255752c1e74f69b31f0216084d","analyzedAt":"2026-09-16T18:14:43.978Z","contentChangedAt":"2026-09-16T18:14:43.978Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}