mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix: invalidate ObjectPermissionTable cache alongside team cache
_invalidate_team_cache only cleared the team object cache but not the ObjectPermissionTable cache. After add_mcp_server_to_team, the team was re-fetched from DB but its object_permission was served from stale cache, causing newly created servers to not appear in the list. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
bb019c8920
commit
e4611faf58
1 changed files with 12 additions and 4 deletions
|
|
@ -366,11 +366,17 @@ async def validate_key_mcp_servers_against_team(
|
|||
)
|
||||
|
||||
|
||||
def _invalidate_team_cache(team_id: str) -> None:
|
||||
"""Invalidate the cached team object so subsequent reads see updated data."""
|
||||
def _invalidate_team_cache(
|
||||
team_id: str, object_permission_id: Optional[str] = None
|
||||
) -> None:
|
||||
"""Invalidate the cached team object and its ObjectPermissionTable so subsequent reads see updated data."""
|
||||
from litellm.proxy.proxy_server import user_api_key_cache
|
||||
|
||||
user_api_key_cache.delete_cache(key="team_id:{}".format(team_id))
|
||||
if object_permission_id:
|
||||
user_api_key_cache.delete_cache(
|
||||
key="object_permission_id:{}".format(object_permission_id)
|
||||
)
|
||||
|
||||
|
||||
async def add_mcp_server_to_team(
|
||||
|
|
@ -429,7 +435,7 @@ async def add_mcp_server_to_team(
|
|||
)
|
||||
|
||||
# Invalidate team cache so the updated mcp_servers list is visible immediately
|
||||
_invalidate_team_cache(team_id)
|
||||
_invalidate_team_cache(team_id, object_permission_id)
|
||||
|
||||
|
||||
async def remove_mcp_server_from_team(
|
||||
|
|
@ -464,4 +470,6 @@ async def remove_mcp_server_from_team(
|
|||
)
|
||||
|
||||
# Invalidate team cache so the updated mcp_servers list is visible immediately
|
||||
_invalidate_team_cache(team_id)
|
||||
_invalidate_team_cache(
|
||||
team_id, team.object_permission_id if team else None
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue