{"record":{"id":"8a3a20d19e1a26c4","repo":"BerriAI/litellm","slug":"user-already-exists-with-username-user-username","errorCode":null,"errorMessage":"User already exists with username: {user.userName}","messagePattern":"User already exists with username: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"error","filePath":"litellm/proxy/management_endpoints/scim/scim_v2.py","lineNumber":1426,"sourceCode":")\nasync def create_user(\n    user: SCIMUser = Body(...),\n):\n    \"\"\"\n    Create a user according to SCIM v2 protocol\n    \"\"\"\n    try:\n        verbose_proxy_logger.debug(\"SCIM CREATE USER request: %s\", user.model_dump())\n        prisma_client: Final = await _get_prisma_client_or_raise_exception()\n\n        # Extract data from SCIM user\n        user_data: Final = _extract_scim_user_data(user)\n\n        # Check if user already exists\n        if user.userName:\n            existing_user = await _table(UserRepository(prisma_client)).find_unique(where={\"user_id\": user.userName})\n            if existing_user:\n                raise HTTPException(\n                    status_code=409,\n                    detail={\"error\": f\"User already exists with username: {user.userName}\"},\n                )\n\n        # Create user in database\n        user_id: Final = user.userName or str(uuid.uuid4())\n        metadata: Final = _build_scim_metadata(\n            user_data[\"given_name\"],\n            user_data[\"family_name\"],\n            enterprise=user_data[\"enterprise\"],\n            entitlements=user_data[\"entitlements\"],\n            roles=user_data[\"roles\"],\n        )\n\n        default_role: Final = _default_scim_user_role()\n        admin_group: Final = await _get_scim_admin_group()\n        resolved_role: Final = _resolve_scim_user_role(user.groups or [], admin_group, default_role)\n","sourceCodeStart":1408,"sourceCodeEnd":1444,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/scim/scim_v2.py#L1408-L1444","documentation":"SCIM POST /Users: the provided userName is used as the LiteLLM user_id, and a lookup shows a user already exists with it. Creating a duplicate is refused with 409-style conflict semantics (HTTPException), pushing clients toward GET/PUT on the existing user.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/scim/scim_v2.py:1426 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a different userName, or update the existing user via PATCH /Users/{id}."],"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-14T05:17:10.506Z"}