BerriAI/litellm · error · Exception

An error occurred: {str(e)}, blocked_user_list={blocked_user

Error message

An error occurred: {str(e)}, blocked_user_list={blocked_user_list}

What it means

Thrown by the BlockedUserList hook constructor when opening the blocked_user_list file raises an exception other than FileNotFoundError (captured by the broad `except Exception`). The real cause is preserved only as str(e) inside the message. Hook initialization aborts, preventing proxy startup.

Source

Thrown at enterprise/enterprise_hooks/blocked_user_list.py:43

        blocked_user_list = litellm.blocked_user_list
        if blocked_user_list is None:
            self.blocked_user_list = None
            return

        if isinstance(blocked_user_list, list):
            self.blocked_user_list = blocked_user_list

        if isinstance(blocked_user_list, str):  # assume it's a filepath
            try:
                with open(blocked_user_list, "r") as file:
                    data = file.read()
                    self.blocked_user_list = data.split("\n")
            except FileNotFoundError:
                raise Exception(
                    f"File not found. blocked_user_list={blocked_user_list}"
                )
            except Exception as e:
                raise Exception(
                    f"An error occurred: {str(e)}, blocked_user_list={blocked_user_list}"
                )

    def print_verbose(self, print_statement, level: Literal["INFO", "DEBUG"] = "DEBUG"):
        if level == "INFO":
            verbose_proxy_logger.info(print_statement)
        elif level == "DEBUG":
            verbose_proxy_logger.debug(print_statement)

        if litellm.set_verbose is True:
            print(print_statement)  # noqa

    async def async_pre_call_hook(
        self,
        user_api_key_dict: UserAPIKeyAuth,
        cache: DualCache,
        data: dict,
        call_type: str,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Read {str(e)} in the message to identify the underlying OSError.
  2. Make the file readable by the proxy service account (chmod 644 / appropriate chown).
  3. Ensure the path is a regular text file, one user ID per line, UTF-8 encoded.
  4. Pass an inline Python list of user IDs instead of a file path if file management is the problem.
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def can_read(p: str) -> bool:
    path = Path(p)
    try:
        with path.open("r", encoding="utf-8") as f:
            f.read()
        return True
    except OSError:
        return False

assert can_read("/etc/litellm/blocked_users.txt")

Try / catch

try:
    hook = BLOCKED_USER_LIST(blocked_user_list=path)
except Exception as e:
    logger.error("blocklist init failed: %s", e)  # str(e) carries the OSError
    raise

Prevention

When it happens

Trigger: blocked_user_list points at an existing but unreadable resource: PermissionError, IsADirectoryError, or a decode error while reading the file contents.

Common situations: Secret files mounted with root-only permissions while the proxy runs as a non-root user; path accidentally pointing at a directory; file written in a non-UTF-8 encoding.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/ecbca266da31fafe. Report an issue: GitHub.