666ghj/MiroFish · critical · RuntimeError

ZEP_API_KEY must be supplied through the process environment

Error message

ZEP_API_KEY must be supplied through the process environment

What it means

Raised by _require_process_api_key in backend/scripts/validate_zep_cloud_integration.py when the module-level _PROCESS_ZEP_API_KEY is empty. The validator deliberately requires the key to come from the process environment captured at startup, so it validates the same configuration path production uses rather than accepting a late-supplied key. It is a RuntimeError raised before any Zep Cloud interaction.

Source

Thrown at backend/scripts/validate_zep_cloud_integration.py:228

            "source_targets": [{"source": "Company", "target": "Company"}],
        },
    ],
}


def _uuid(value: Any) -> str:
    return str(getattr(value, "uuid_", None) or getattr(value, "uuid", ""))


def _status_code(error: Exception) -> int | None:
    direct = getattr(error, "status_code", None)
    response = getattr(error, "response", None)
    return direct or getattr(response, "status_code", None)


def _require_process_api_key() -> str:
    if not _PROCESS_ZEP_API_KEY:
        raise RuntimeError(
            "ZEP_API_KEY must be supplied through the process environment"
        )
    return _PROCESS_ZEP_API_KEY


def _drain_updater_after_failure(
    updater: Any,
    *,
    started: bool,
    stop_attempted: bool,
) -> tuple[bool, Exception | None]:
    """Make one safe drain attempt when the main flow did not call stop()."""

    if not started:
        return True, None
    if stop_attempted:
        return False, None
    try:

View on GitHub (pinned to b5b53acc57)

Solutions

  1. Run inline: ZEP_API_KEY=... python scripts/validate_zep_cloud_integration.py.
  2. Or export in the launching shell before starting the script — the capture happens at import/startup time.
  3. In CI, register ZEP_API_KEY as the job's environment/secret variable.

Example fix

# before
$ python scripts/validate_zep_cloud_integration.py  # RuntimeError

# after
$ ZEP_API_KEY=zep_... python scripts/validate_zep_cloud_integration.py
Defensive patterns

Strategy: validation

Validate before calling

import os

def process_zep_key_present() -> bool:
    return bool(os.environ.get("ZEP_API_KEY"))

Prevention

When it happens

Trigger: Running validate_zep_cloud_integration.py without ZEP_API_KEY exported in the launching shell — a .env the script does not load, a differently-named CI secret (e.g. ZEP_KEY), or setting the variable after the interpreter already started.

Common situations: Operator assumes the script reads .env like the backend; CI defines the secret under the wrong name; systemd/sudo scrubs the environment.

Related errors


AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14). Data as JSON: /api/errors/2a816c1bbf573fbb. Report an issue: GitHub.