litellm icon indicating copy to clipboard operation
litellm copied to clipboard

[Bug]: 'NoneType' object is not iterable in _get_user_info_for_proxy_admin()

Open bgeneto opened this issue 1 year ago • 0 comments

What happened?

Every time I log-in to the LiteLLM Admin Panel ui I've got the following error notification message:

image

Looking at the stack trace, the error originates in litellm/proxy/management_endpoints/internal_user_endpoints.py.

Specifically:

  1. The user_info() function calls _get_user_info_for_proxy_admin().
  2. Inside _get_user_info_for_proxy_admin(), there's a for loop: for key in _keys_in_db:.
  3. The error occurs because _keys_in_db is None at the time the loop is executed. This means that whatever logic is supposed to populate _keys_in_db before the loop is not working correctly and is returning None instead of an iterable (like a list).

Here is the relevant log output in json format:

{"message": "litellm.proxy.proxy_server.user_info(): Exception occured - 'NoneType' object is not iterable", "level": "ERROR", "timestamp": "2024-12-06T13:45:06.592580", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.11/site-packages/litellm/proxy/management_endpoints/internal_user_endpoints.py\", line 308, in user_info\n    return await _get_user_info_for_proxy_admin()\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/site-packages/litellm/proxy/management_endpoints/internal_user_endpoints.py\", line 431, in _get_user_info_for_proxy_admin\n    for key in _keys_in_db:\nTypeError: 'NoneType' object is not iterable"}

Relevant log output

{"message": "litellm.proxy.proxy_server.user_info(): Exception occured - 'NoneType' object is not iterable", "level": "ERROR", "timestamp": "2024-12-06T13:45:06.592580", "stacktrace": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.11/site-packages/litellm/proxy/management_endpoints/internal_user_endpoints.py\", line 308, in user_info\n    return await _get_user_info_for_proxy_admin()\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/site-packages/litellm/proxy/management_endpoints/internal_user_endpoints.py\", line 431, in _get_user_info_for_proxy_admin\n    for key in _keys_in_db:\nTypeError: 'NoneType' object is not iterable"}

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.53.7

Twitter / LinkedIn details

No response

bgeneto avatar Dec 06 '24 13:12 bgeneto