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
- Read {str(e)} in the message to identify the underlying OSError.
- Make the file readable by the proxy service account (chmod 644 / appropriate chown).
- Ensure the path is a regular text file, one user ID per line, UTF-8 encoded.
- 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
- chmod the blocklist to 644 and chown to the proxy user at deploy time.
- Avoid pointing the setting at directories; validate with os.path.isfile first.
- Store blocklists as UTF-8 text.
- Pass an inline list to eliminate filesystem failure modes in orchestrated environments.
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
- File not found. blocked_user_list={blocked_user_list}
- An error occurred: {str(e)}, file_path={file_path}
- File not found. file_path={file_path}
- User blocked from making LLM API Calls. User={user}
- Missing google.cloud package. Run `pip install --upgrade goo
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/ecbca266da31fafe.
Report an issue: GitHub.