BerriAI/litellm · error · UpError

{resolved_path} contains invalid or unexpected JSON; cannot

Error message

{resolved_path} contains invalid or unexpected JSON; cannot proceed safely.

What it means

The autoroute PID record file exists but fails Pydantic validation or contains unexpected JSON, so a running ephemeral proxy cannot be safely identified or stopped; the command aborts rather than guessing.

Source

Thrown at litellm/proxy/client/cli/commands/autoroute/process.py:133

    resolved_path.parent.mkdir(parents=True, exist_ok=True)
    with open(resolved_path, "w") as f:
        json.dump(
            {"pid": record.pid, "port": record.port, "config_path": record.config_path, "log_path": record.log_path},
            f,
            indent=2,
        )


def read_pid_record(path: Path | None = None) -> PidRecord | None:
    resolved_path: Final = path if path is not None else PID_RECORD_PATH
    if not resolved_path.exists():
        return None
    with open(resolved_path, "r") as f:
        content: Final = f.read()
    try:
        return _PID_RECORD_ADAPTER.validate_json(content)
    except ValidationError:
        raise UpError(f"{resolved_path} contains invalid or unexpected JSON; cannot proceed safely.")


def clear_pid_record(path: Path | None = None) -> None:
    resolved_path: Final = path if path is not None else PID_RECORD_PATH
    resolved_path.unlink(missing_ok=True)


def is_running(pid: int) -> bool:
    try:
        os.kill(pid, 0)
    except ProcessLookupError:
        return False
    except PermissionError:
        return True
    return True


def terminate(pid: int, grace_period: float = 5.0) -> None:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Fix the JSON in the referenced file so it parses as expected.
  2. Restore the file from a known-good copy.

Example fix

python -m json.tool <file> to validate the JSON.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/client/cli/commands/autoroute/process.py:133 when the library encounters an invalid state.

Common situations: A CLI state/config file contains invalid or unexpected JSON.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/916a6da040dd0311. Report an issue: GitHub.