{"record":{"id":"64f4aa84dc992809","repo":"BerriAI/litellm","slug":"only-proxy-admin-or-team-admin-can-modify-team-mod","errorCode":null,"errorMessage":"Only proxy admin or team admin can modify team models","messagePattern":"Only proxy admin or team admin can modify team models","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/management_endpoints/team_endpoints.py","lineNumber":5294,"sourceCode":"\n    # Get existing team\n    team_row: Final = await _team_db(prisma_client).find_unique(where={\"team_id\": data.team_id})\n\n    if team_row is None:\n        raise HTTPException(\n            status_code=404,\n            detail={\"error\": f\"Team not found, passed team_id={data.team_id}\"},\n        )\n\n    team_obj: Final = LiteLLM_TeamTable.model_validate(team_row.model_dump())\n\n    # Authorization check - only proxy admin, team admin, or org admin can add models\n    if (\n        user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN.value\n        and not _is_user_team_admin(user_api_key_dict=user_api_key_dict, team_obj=team_obj)\n        and not await _is_user_org_admin_for_team(user_api_key_dict=user_api_key_dict, team_obj=team_obj)\n    ):\n        raise HTTPException(\n            status_code=403,\n            detail={\"error\": \"Only proxy admin or team admin can modify team models\"},\n        )\n\n    # Atomic array append with dedup at the database level so concurrent\n    # BYOK model creates don't overwrite each other's team.models entries.\n    # When the team currently has models=[] (unrestricted access), the\n    # CASE expression inserts the 'all-proxy-models' sentinel first.\n    models_to_add: Final = list(data.models)\n    await prisma_client.db.execute_raw(\n        'UPDATE \"LiteLLM_TeamTable\" '\n        \"SET models = (\"\n        \"  SELECT ARRAY(SELECT DISTINCT unnest(\"\n        \"    CASE WHEN cardinality(COALESCE(models, ARRAY[]::text[])) = 0 \"\n        \"         THEN ARRAY['all-proxy-models']::text[] \"\n        \"         ELSE models \"\n        \"    END || $1::text[]\"\n        \"  ))\"","sourceCodeStart":5276,"sourceCodeEnd":5312,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/team_endpoints.py#L5276-L5312","documentation":"Error \"Only proxy admin or team admin can modify team models\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/team_endpoints.py:5294 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call with a proxy admin key or a team admin key for the target 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"}