{"record":{"id":"f070b0e65e1872c7","repo":"diegosouzapw/OmniRoute","slug":"agentbridge-upstream-ca-cert-path-does-not-exist","errorCode":null,"errorMessage":"AGENTBRIDGE_UPSTREAM_CA_CERT path does not exist: ${pemPath}","messagePattern":"AGENTBRIDGE_UPSTREAM_CA_CERT path does not exist: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/mitm/upstreamTrust.ts","lineNumber":31,"sourceCode":" * Configure undici's global dispatcher to trust a custom CA certificate.\n *\n * `undici` is loaded lazily (only when a CA is actually being configured) so\n * that merely importing this module — which happens transitively from every\n * MITM handler via `base.ts` — does not eagerly pull in undici's full index.\n * That keeps the module importable in test/toolchain environments where the\n * installed undici may be incompatible with the running Node version, and\n * avoids loading a heavy dependency for the common no-CA path.\n *\n * @param pemPath - Absolute path to the PEM file. If undefined/empty, no-op.\n * @throws {Error} With a safe error message (no stack trace) if pemPath is set\n *   but the file does not exist.\n */\nexport function configureUpstreamCa(pemPath?: string): void {\n  if (!pemPath) return;\n\n  if (!existsSync(pemPath)) {\n    // Safe error: message only contains the user-supplied path (no stack trace).\n    throw new Error(\n      `AGENTBRIDGE_UPSTREAM_CA_CERT path does not exist: ${pemPath}`,\n    );\n  }\n\n  const ca = readFileSync(pemPath, \"utf8\");\n  const require = createRequire(import.meta.url);\n  const { Agent, setGlobalDispatcher } = require(\"undici\") as typeof import(\"undici\");\n  setGlobalDispatcher(new Agent({ connect: { ca } }));\n}\n","sourceCodeStart":13,"sourceCodeEnd":41,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/mitm/upstreamTrust.ts#L13-L41","documentation":"Configuration validation error raised while configuring undici to trust a custom upstream CA: the AGENTBRIDGE_UPSTREAM_CA_CERT environment variable points to a PEM file path that does not exist on disk. It fires at MITM/upstream-trust setup time when the operator supplied a bad or stale path.","triggerScenarios":"Thrown at src/mitm/upstreamTrust.ts:31 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the path in AGENTBRIDGE_UPSTREAM_CA_CERT is absolute and exists","Mount or copy the CA PEM file into the container/host the proxy runs on","Correct or unset the env var if the custom CA is no longer needed","Check for typos and for the file being deleted by cleanup or volume remounts"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}