mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(proxy): keep a team on a /user/bulk_new row when the roster already lists that user id
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
4285f1dfb0
commit
0c9e0c407e
2 changed files with 13 additions and 1 deletions
|
|
@ -572,7 +572,7 @@ async def _write_team_roster(
|
|||
return _TeamWrite(
|
||||
team_id=team.team_id,
|
||||
after=after,
|
||||
added=frozenset(member.user_id for member in new_members),
|
||||
added=frozenset(member.user_id for member in members),
|
||||
failed=MappingProxyType({}),
|
||||
)
|
||||
except Exception as exc: # noqa: BLE001 # the team write failure is reported on each affected row
|
||||
|
|
|
|||
|
|
@ -220,6 +220,18 @@ async def test_creates_users_and_team_membership_in_every_store():
|
|||
]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_user_id_already_on_the_roster_keeps_the_team_and_is_not_added_twice():
|
||||
prisma = _FakePrisma(teams=[_team("t1", [Member(user_id="u1", role="user")])])
|
||||
response = await _run(prisma, [{"user_id": "u1", "teams": ["t1"]}, {"user_id": "u2", "teams": ["t1"]}])
|
||||
|
||||
assert [r.success for r in response.results] == [True, True]
|
||||
assert [r.teams for r in response.results] == [("t1",), ("t1",)]
|
||||
assert [r.error for r in response.results] == [None, None]
|
||||
assert prisma.db.litellm_usertable.rows["u1"].teams == ["t1"]
|
||||
assert [m.user_id for m in prisma.db.litellm_teamtable.rows["t1"].members_with_roles] == ["u1", "u2"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_one_insert_and_one_locked_write_per_team():
|
||||
prisma = _FakePrisma(teams=[_team("t1"), _team("t2")])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue