{"record":{"id":"58dcaa5b4750b76d","repo":"BerriAI/litellm","slug":"only-a-proxy-admin-can-delete-a-model-whose-team-h","errorCode":null,"errorMessage":"Only a proxy admin can delete a model whose team has been deleted.","messagePattern":"Only a proxy admin can delete a model whose team has been deleted\\.","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/management_endpoints/model_management_endpoints.py","lineNumber":1511,"sourceCode":"        model_params: Deployment,\n        user_api_key_dict: UserAPIKeyAuth,\n        prisma_client: PrismaClient,\n        premium_user: bool,\n        allow_missing_team: bool = False,\n    ) -> Literal[True]:\n        ## Check team model auth\n        if model_params.model_info is not None and model_params.model_info.team_id is not None:\n            team_obj_row: Final = await _repo_team_table(prisma_client).find_unique(\n                where={\"team_id\": model_params.model_info.team_id}\n            )\n            if team_obj_row is None:\n                # The team was deleted. Callers that opt in (e.g. model deletion) may\n                # act on the orphaned model, but only as a proxy admin -- without the\n                # team there is no team-admin membership left to verify.\n                if allow_missing_team:\n                    if user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN:\n                        return True\n                    raise HTTPException(\n                        status_code=403,\n                        detail={\"error\": \"Only a proxy admin can delete a model whose team has been deleted.\"},\n                    )\n                raise HTTPException(\n                    status_code=400,\n                    detail={\"error\": f\"Team id={model_params.model_info.team_id} does not exist in db\"},\n                )\n            team_obj: Final = LiteLLM_TeamTable.model_validate(team_obj_row.model_dump())\n\n            return ModelManagementAuthChecks.can_user_make_team_model_call(\n                team_id=model_params.model_info.team_id,\n                user_api_key_dict=user_api_key_dict,\n                team_obj=team_obj,\n                premium_user=premium_user,\n            )\n        ## Check non-team model auth\n        elif user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:\n            raise HTTPException(","sourceCodeStart":1493,"sourceCodeEnd":1529,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/model_management_endpoints.py#L1493-L1529","documentation":"Orphaned-team guard in the model auth checks: the model's model_info.team_id references a team that has been deleted from the DB. Callers that do not pass allow_missing_team are rejected — only a proxy admin may act on such orphaned models, preventing non-admins from exploiting dangling team references.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/model_management_endpoints.py:1511 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a PROXY_ADMIN API key to delete a model whose team has been deleted."],"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"}