{"record":{"id":"9ef1694b5e60d144","repo":"BerriAI/litellm","slug":"user-id-does-not-exist-in-litellm-usertable-fix","errorCode":null,"errorMessage":"User id does not exist in 'LiteLLM_UserTable'. Fix this by creating user via `/user/new`.","messagePattern":"User id does not exist in 'LiteLLM_UserTable'\\. Fix this by creating user via `/user/new`\\.","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/management_helpers/user_invitation.py","lineNumber":43,"sourceCode":"\n    current_time: Final = litellm.utils.get_utc_datetime()\n    expires_at: Final = current_time + timedelta(days=7)\n\n    try:\n        response: Final = await InvitationLinkRepository(prisma_client).table.create(\n            data={\n                \"user_id\": data.user_id,\n                \"created_at\": current_time,\n                \"expires_at\": expires_at,\n                \"created_by\": user_api_key_dict.user_id or litellm_proxy_admin_name,\n                \"updated_at\": current_time,\n                \"updated_by\": user_api_key_dict.user_id or litellm_proxy_admin_name,\n            }\n        )\n        return response\n    except Exception as e:\n        if \"Foreign key constraint failed on the field\" in str(e):\n            raise HTTPException(\n                status_code=400,\n                detail={\n                    \"error\": \"User id does not exist in 'LiteLLM_UserTable'. Fix this by creating user via `/user/new`.\"\n                },\n            )\n        raise HTTPException(status_code=500, detail={\"error\": str(e)})\n","sourceCodeStart":25,"sourceCodeEnd":50,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_helpers/user_invitation.py#L25-L50","documentation":"HTTPException raised when creating an invitation link fails because the referenced user_id has no row in LiteLLM_UserTable (Prisma foreign-key violation on the invitation insert). The invited user must be created first via /user/new before an invitation can be issued.","triggerScenarios":"Thrown at litellm/proxy/management_helpers/user_invitation.py:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the user first via POST /user/new, then retry the invitation."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}