{"record":{"id":"4dfc18ef47002e31","repo":"BerriAI/litellm","slug":"user-user-api-key-dict-user-id-not-assigned-to-t","errorCode":null,"errorMessage":"User={user_api_key_dict.user_id} not assigned to team={team_table.team_id}","messagePattern":"User=(.+?) not assigned to team=(.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/management_endpoints/key_management_endpoints.py","lineNumber":363,"sourceCode":"    if assigned_user_id is not None:\n        key_assigned_user_in_team: Final = _get_user_in_team(team_table=team_table, user_id=assigned_user_id)\n\n        if key_assigned_user_in_team is None:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"User={assigned_user_id} not assigned to team={team_table.team_id}\",\n            )\n\n    team_member_object: Final = _get_user_in_team(team_table=team_table, user_id=user_api_key_dict.user_id)\n\n    is_admin: Final = (\n        user_api_key_dict.user_role is not None and user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value\n    )\n\n    if is_admin:\n        return True\n    elif team_member_object is None:\n        raise HTTPException(\n            status_code=400,\n            detail=f\"User={user_api_key_dict.user_id} not assigned to team={team_table.team_id}\",\n        )\n    elif (\n        \"allowed_team_member_roles\" in team_key_generation\n        and team_member_object.role not in team_key_generation[\"allowed_team_member_roles\"]\n    ):\n        raise HTTPException(\n            status_code=400,\n            detail=f\"Team member role {team_member_object.role} not in allowed_team_member_roles={team_key_generation['allowed_team_member_roles']}\",\n        )\n\n    TeamMemberPermissionChecks.does_team_member_have_permissions_for_endpoint(\n        team_member_object=team_member_object,\n        team_table=team_table,\n        route=route,\n    )\n    return True","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/key_management_endpoints.py#L345-L381","documentation":"Error \"User={user_api_key_dict.user_id} not assigned to team={team_table.team_id}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:363 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add your user to the team first (via /team/member_add), then create the key.","Verify the team_id in the request matches the intended team."],"exampleFix":null,"handlingStrategy":null,"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"}