diff --git a/litellm/proxy/management_helpers/utils.py b/litellm/proxy/management_helpers/utils.py index 86beb0636675..7c52b04c4ebb 100644 --- a/litellm/proxy/management_helpers/utils.py +++ b/litellm/proxy/management_helpers/utils.py @@ -295,10 +295,16 @@ async def add_new_member( # same new user is provisioned concurrently), seeding teams on create. # The teams append lives in the filtered update below rather than the # upsert's update branch so an already-existing user does not get a - # duplicate team id. + # duplicate team id. The update branch still has to write something: + # Prisma only compiles an upsert down to INSERT ... ON CONFLICT when it + # is non-empty, and falls back to a racy SELECT-then-INSERT when it is + # not, so this re-states user_id as a no-op rather than being empty. _returned_user = await UserRepository(prisma_client).table.upsert( where={"user_id": new_member.user_id}, - data={"create": {"teams": [team_id], **new_user_defaults}, "update": {}}, + data={ + "create": {"teams": [team_id], **new_user_defaults}, + "update": {"user_id": new_member.user_id}, + }, ) await _append_team_id_if_absent(prisma_client, new_member.user_id, team_id) if _returned_user is not None: diff --git a/tests/e2e/ui/tests/modelsPage/addModel.spec.ts b/tests/e2e/ui/tests/modelsPage/addModel.spec.ts index 17ff1fc3f832..bb8806a9c016 100644 --- a/tests/e2e/ui/tests/modelsPage/addModel.spec.ts +++ b/tests/e2e/ui/tests/modelsPage/addModel.spec.ts @@ -1,5 +1,5 @@ import { test, expect } from "@playwright/test"; -import { ADMIN_STORAGE_PATH, E2E_TEAM_CRUD_ALIAS, E2E_TEAM_CRUD_ID } from "../../constants"; +import { ADMIN_STORAGE_PATH, E2E_TEAM_CRUD_ID } from "../../constants"; import { Role, users } from "../../fixtures/users"; import { navigateToPage } from "../../helpers/navigation"; import { Page } from "../../fixtures/pages"; @@ -56,17 +56,17 @@ test.describe("Add Model", () => { }, }); expect(createResponse.ok()).toBe(true); + const createdModelId = (await createResponse.json()).model_info?.id; + expect(createdModelId, "model id from /model/new").toBeTruthy(); // Navigate to Models + Endpoints await page.goto("/ui"); await page.getByText("Models + Endpoints").click(); - // Click the new model row to open its detail view. The table renders - // a clickable outer row plus a nested detail row for the same model, - // so we target the first match (outer row) explicitly. - const modelRow = page.locator("tr", { hasText: modelName }).first(); - await expect(modelRow).toBeVisible({ timeout: 10_000 }); - await modelRow.click(); + // The Model ID cell is the drill-in control; the row itself is not clickable. + const modelIdCell = page.getByTestId(`model-id-${createdModelId}`); + await expect(modelIdCell).toBeVisible({ timeout: 10_000 }); + await modelIdCell.click(); await expect(page.getByText("Back to Models").first()).toBeVisible({ timeout: 10_000 }); @@ -137,11 +137,11 @@ test.describe("Add Model", () => { await page.waitForTimeout(2000); // Search for the model we just added - await page.locator('input[placeholder="Search model names..."]').fill("claude-haiku-4-5"); + await page.getByPlaceholder("Search model names").fill("claude-haiku-4-5"); await page.waitForTimeout(1000); // Verify the model appears in the results count (not "Showing 0 results") - await expect(page.getByTestId("models-results-count")).toHaveText(/Showing \d+ - \d+ of \d+ results/, { + await expect(page.getByTestId("pagination-range")).toHaveText(/Showing \d+-\d+ of \d+/, { timeout: 15_000, }); @@ -228,24 +228,24 @@ test.describe("Add Model", () => { // searching. await page.waitForTimeout(2000); - await page.locator('input[placeholder="Search model names..."]').fill("cohere"); + await page.getByPlaceholder("Search model names").fill("cohere"); await page.waitForTimeout(1000); // Confirm the search returned at least one result — gives a clear // failure message when the table is empty instead of timing out on a // row assertion. - await expect(page.getByTestId("models-results-count")).toHaveText(/Showing \d+ - \d+ of \d+ results/, { + await expect(page.getByTestId("pagination-range")).toHaveText(/Showing \d+-\d+ of \d+/, { timeout: 15_000, }); - // Stronger than "alias appears somewhere in tbody" — pin the assertion + // Stronger than "the team appears somewhere in tbody" — pin the assertion // to a single row that has BOTH the cohere model_name AND the seeded - // team alias, so a stale cohere row from "Add wildcard route" (no team) - // can't satisfy the check. + // team, so a stale cohere row from "Add wildcard route" (no team) can't + // satisfy the check. The Team ID column renders the id, not the alias. const teamCohereRow = page .locator("table tbody tr") .filter({ hasText: "cohere/" }) - .filter({ hasText: E2E_TEAM_CRUD_ALIAS }); + .filter({ hasText: E2E_TEAM_CRUD_ID }); await expect(teamCohereRow).toHaveCount(1, { timeout: 15_000 }); } finally { await deleteTeamScopedCohereModels(); @@ -281,11 +281,11 @@ test.describe("Add Model", () => { await page.waitForTimeout(2000); // Search for the wildcard model - await page.locator('input[placeholder="Search model names..."]').fill("cohere"); + await page.getByPlaceholder("Search model names").fill("cohere"); await page.waitForTimeout(1000); // Verify the model appears in the results count (not "Showing 0 results") - await expect(page.getByTestId("models-results-count")).toHaveText(/Showing \d+ - \d+ of \d+ results/, { + await expect(page.getByTestId("pagination-range")).toHaveText(/Showing \d+-\d+ of \d+/, { timeout: 15_000, }); diff --git a/tests/e2e/ui/tests/modelsPage/clearCustomPricing.spec.ts b/tests/e2e/ui/tests/modelsPage/clearCustomPricing.spec.ts index 877c7f8c5556..e67dcb96f367 100644 --- a/tests/e2e/ui/tests/modelsPage/clearCustomPricing.spec.ts +++ b/tests/e2e/ui/tests/modelsPage/clearCustomPricing.spec.ts @@ -67,9 +67,10 @@ test.describe("Clear custom pricing on a deployment", () => { await page.goto("/ui"); await page.getByText("Models + Endpoints").click(); - const modelRow = page.locator("tr", { hasText: modelName }).first(); - await expect(modelRow).toBeVisible({ timeout: 15_000 }); - await modelRow.click(); + // The Model ID cell is the drill-in control; the row itself is not clickable. + const modelIdCell = page.getByTestId(`model-id-${createdModelId}`); + await expect(modelIdCell).toBeVisible({ timeout: 15_000 }); + await modelIdCell.click(); await expect(page.getByText("Back to Models").first()).toBeVisible({ timeout: 10_000, }); diff --git a/tests/llm_translation/test_openai.py b/tests/llm_translation/test_openai.py index 1fec7665daac..2cdaad88cd52 100644 --- a/tests/llm_translation/test_openai.py +++ b/tests/llm_translation/test_openai.py @@ -518,7 +518,7 @@ async def test_openai_codex_stream(sync_mode): from litellm.main import stream_chunk_builder kwargs = { - "model": "openai/gpt-5.2-codex", + "model": "openai/gpt-5.3-codex", "messages": [{"role": "user", "content": "Hey!"}], "stream": True, } @@ -550,7 +550,7 @@ async def test_openai_codex(sync_mode): { "model_name": "openai-codex-mini-latest", "litellm_params": { - "model": "openai/gpt-5.2-codex", + "model": "openai/gpt-5.3-codex", }, } ] diff --git a/tests/test_litellm/proxy/management_helpers/test_management_helpers_utils.py b/tests/test_litellm/proxy/management_helpers/test_management_helpers_utils.py index 01e5414a469a..504414ea6351 100644 --- a/tests/test_litellm/proxy/management_helpers/test_management_helpers_utils.py +++ b/tests/test_litellm/proxy/management_helpers/test_management_helpers_utils.py @@ -1076,6 +1076,13 @@ async def test_add_new_member_creates_missing_user_atomically_via_upsert(): would race a check-then-create into a duplicate-key failure. The upsert seeds teams on create, and the filtered append is a no-op because the team is already present on the freshly created row. + + Calling upsert is not on its own enough to be atomic: Prisma only compiles it + down to a single INSERT ... ON CONFLICT when the update branch is non-empty, + and otherwise emits SELECT-then-INSERT, which loses the race. That is how + parallel /team/new calls naming the same new member started returning 500 + "Unique constraint failed on the fields: (user_id)", so the shape of both + branches is pinned here. """ from litellm.proxy._types import LitellmUserRoles @@ -1114,5 +1121,7 @@ async def test_add_new_member_creates_missing_user_atomically_via_upsert(): # non-atomic standalone create that could race under concurrent provisioning mock_prisma_client.db.litellm_usertable.upsert.assert_called_once() mock_prisma_client.db.litellm_usertable.create.assert_not_called() - create_data = mock_prisma_client.db.litellm_usertable.upsert.call_args.kwargs["data"]["create"] - assert create_data["teams"] == ["team-1"] + upsert_data = mock_prisma_client.db.litellm_usertable.upsert.call_args.kwargs["data"] + assert upsert_data["create"]["teams"] == ["team-1"] + assert upsert_data["update"], "empty update branch degrades the upsert to a racy SELECT-then-INSERT" + assert "teams" not in upsert_data["update"]