diegosouzapw/OmniRoute · error

AGENTBRIDGE_UPSTREAM_CA_CERT path does not exist

Error message

AGENTBRIDGE_UPSTREAM_CA_CERT path does not exist: ${pemPath}

What it means

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.

Solutions

  1. Verify the path in AGENTBRIDGE_UPSTREAM_CA_CERT is absolute and exists
  2. Mount or copy the CA PEM file into the container/host the proxy runs on
  3. Correct or unset the env var if the custom CA is no longer needed
  4. Check for typos and for the file being deleted by cleanup or volume remounts
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/mitm/upstreamTrust.ts:31 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/f070b0e65e1872c7. Report an issue: GitHub.

Appendix: source

Thrown at src/mitm/upstreamTrust.ts:31

 * Configure undici's global dispatcher to trust a custom CA certificate.
 *
 * `undici` is loaded lazily (only when a CA is actually being configured) so
 * that merely importing this module — which happens transitively from every
 * MITM handler via `base.ts` — does not eagerly pull in undici's full index.
 * That keeps the module importable in test/toolchain environments where the
 * installed undici may be incompatible with the running Node version, and
 * avoids loading a heavy dependency for the common no-CA path.
 *
 * @param pemPath - Absolute path to the PEM file. If undefined/empty, no-op.
 * @throws {Error} With a safe error message (no stack trace) if pemPath is set
 *   but the file does not exist.
 */
export function configureUpstreamCa(pemPath?: string): void {
  if (!pemPath) return;

  if (!existsSync(pemPath)) {
    // Safe error: message only contains the user-supplied path (no stack trace).
    throw new Error(
      `AGENTBRIDGE_UPSTREAM_CA_CERT path does not exist: ${pemPath}`,
    );
  }

  const ca = readFileSync(pemPath, "utf8");
  const require = createRequire(import.meta.url);
  const { Agent, setGlobalDispatcher } = require("undici") as typeof import("undici");
  setGlobalDispatcher(new Agent({ connect: { ca } }));
}

View on GitHub (pinned to a179ffed5b)