{"record":{"id":"24ffb6bfd9e4aca3","repo":"BerriAI/litellm","slug":"user-user-api-key-dict-user-id-not-authorized-to","errorCode":null,"errorMessage":"User={user_api_key_dict.user_id} not authorized to access this team={team_table.team_id}","messagePattern":"User=(.+?) not authorized to access this team=(.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/management_endpoints/team_endpoints.py","lineNumber":4049,"sourceCode":"                },\n            )\n        else:\n            raise HTTPException(\n                status_code=403,\n                detail={\n                    \"error\": f\"API key not authorized to access this team={team_table.team_id}. No user_id or team_id associated with this key.\"\n                },\n            )\n\n    # Check direct team membership\n    if user_api_key_dict.user_id in [m.user_id for m in team_table.members_with_roles]:\n        return\n\n    # Check if user is an org admin for the team's organization\n    if await _is_user_org_admin_for_team(user_api_key_dict=user_api_key_dict, team_obj=team_table):\n        return\n\n    raise HTTPException(\n        status_code=403,\n        detail={\"error\": f\"User={user_api_key_dict.user_id} not authorized to access this team={team_table.team_id}\"},\n    )\n\n\nasync def _add_team_member_budget_table(\n    team_member_budget_id: str,\n    prisma_client: PrismaClient,\n    team_info_response_object: TeamInfoResponseObjectTeamTable,\n) -> TeamInfoResponseObjectTeamTable:\n    try:\n        team_budget: Final = await _budget_db(prisma_client).find_unique(where={\"budget_id\": team_member_budget_id})\n        return team_info_response_object.model_copy(update={\"team_member_budget_table\": team_budget})\n    except Exception:\n        verbose_proxy_logger.info(\n            \"Team member budget table not found, passed team_member_budget_id=%s\", team_member_budget_id\n        )\n","sourceCodeStart":4031,"sourceCodeEnd":4067,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/team_endpoints.py#L4031-L4067","documentation":"Error \"User={user_api_key_dict.user_id} not authorized to access this team={team_table.team_id}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/team_endpoints.py:4049 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a key whose user is a member or admin of the target team, or a proxy admin key."],"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"}