{"record":{"id":"42e5b27ba227ad4d","repo":"BerriAI/litellm","slug":"f-user-user-id-not-found","errorCode":null,"errorMessage":"f\"User {user_id} not found\"","messagePattern":"f\"User (.+?) not found\"","errorType":"http","errorClass":"HTTPException","httpStatus":404,"severity":"error","filePath":"litellm/proxy/management_endpoints/internal_user_endpoints.py","lineNumber":888,"sourceCode":"        user_id = _normalize_user_info_user_id(request=request, user_id=user_id)\n        _enforce_user_info_access(user_id=user_id, user_api_key_dict=user_api_key_dict)\n\n        if prisma_client is None:\n            raise Exception(\n                \"Database not connected. Connect a database to your proxy - https://docs.litellm.ai/docs/simple_proxy#managing-auth---virtual-keys\"\n            )\n        if user_id is None and _user_has_admin_view(user_api_key_dict):\n            return await _get_user_info_for_proxy_admin(user_api_key_dict=user_api_key_dict)\n        elif user_id is None:\n            user_id = user_api_key_dict.user_id\n        ## GET USER ROW ##\n\n        user_info = None\n        if user_id is not None:\n            user_info = await prisma_client.get_data(user_id=user_id)\n\n        if user_info is None:\n            raise HTTPException(\n                status_code=404,\n                detail=f\"User {user_id} not found\",\n            )\n\n        team_list, teams_1 = await _get_user_info_teams(\n            prisma_client=prisma_client,\n            user_id=user_id,\n            user_info=user_info,\n            user_api_key_dict=user_api_key_dict,\n        )\n\n        ## GET ALL KEYS ##\n        keys: Final = await prisma_client.get_data(\n            user_id=user_id,\n            table_name=\"key\",\n            query_type=\"find_all\",\n        )\n","sourceCodeStart":870,"sourceCodeEnd":906,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/internal_user_endpoints.py#L870-L906","documentation":"After the ownership check passes, GET /user/info fetches the row with prisma_client.get_data(user_id=...). If no row matches the exact id string, LiteLLM returns 404 'User {user_id} not found'. The lookup is exact-match, so encoding differences ('+' decoded to a space), typos, or a user_email passed where a user_id is expected all miss.","triggerScenarios":"GET /user/info?user_id=<deleted or never-created id>; passing an email in a format that differs from the stored user_id; '+' in the id decoded to a space so the exact-match fetch returns None.","commonSituations":"Referencing users removed by cleanup jobs; ids copy-pasted with whitespace or encoding damage; querying a user whose /user/new call failed earlier in the flow.","solutions":["List users with GET /user/list and copy the exact user_id","URL-encode the id (%2B for '+') so it matches the stored value","Create the user first via POST /user/new (or SSO login) if it must exist"],"exampleFix":"# before\nGET /user/info?user_id=myuser    # 404 User myuser not found\n\n# after\nGET /user/list                   # find exact id, e.g. 'my-user'\nGET /user/info?user_id=my-user   # 200","handlingStrategy":"validation","validationCode":"import requests\n\ndef user_exists(base_url: str, headers: dict, user_id: str) -> bool:\n    r = requests.get(f\"{base_url}/user/list\", headers=headers, timeout=10)\n    r.raise_for_status()\n    return any(u.get(\"user_id\") == user_id for u in r.json().get(\"data\", []))","typeGuard":null,"tryCatchPattern":"except requests.HTTPError as e:\n    if e.response is not None and e.response.status_code == 404 and \"not found\" in e.response.text.lower():\n        return None  # missing resource: skip or re-create, do not blind-retry\n    raise","preventionTips":["Persist the exact user_id returned by /user/new and reuse it verbatim","Encode ids containing '+' or '@' with quote(id, safe='')","When deleting users, also purge downstream references so later lookups never 404"],"tags":["litellm","user-management","not-found"],"backgroundTag":"user-not-found","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}