The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(ui): keep team Organization optional for proxy admins in single-org setups (#30861)
yuneng-jianga5b75e8bab4b
diff --git a/ui/litellm-dashboard/src/components/OldTeams.test.tsx b/ui/litellm-dashboard/src/components/OldTeams.test.tsxindex d777ba1b0dc..0b6e5786aaf 100644--- a/ui/litellm-dashboard/src/components/OldTeams.test.tsx+++ b/ui/litellm-dashboard/src/components/OldTeams.test.tsx@@ -1097,3 +1097,52 @@ describe("OldTeams - delete team warning copy", () => {);});});++describe("OldTeams - LIT-2530 organization stays optional for proxy admin with a single org", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ mockTeamInfoView.mockClear();+ vi.mocked(fetchAvailableModelsForTeamOrKey).mockResolvedValue(["gpt-4"]);+ vi.mocked(fetchMCPAccessGroups).mockResolvedValue([]);+ vi.mocked(getGuardrailsList).mockResolvedValue({ guardrails: [] });+ vi.mocked(teamListCall).mockResolvedValue({ teams: [], total: 0, page: 1, page_size: 100, total_pages: 1 });+ vi.mocked(teamCreateCall).mockResolvedValue({+ team_id: "new-team-1",+ team_alias: "No Org Team",+ models: ["gpt-4"],+ organization_id: null,+ keys: [],+ members_with_roles: [],+ spend: 0,+ });+ mockUseOrganizations.mockReturnValue({+ data: [{ organization_id: "org-1", organization_alias: "Org 1", models: [], members: [] }],+ });+ });++ it("creates a team with no organization when exactly one organization exists", async () => {+ renderWithQueryClient(<OldTeams accessToken="test-token" userID="user-123" userRole="Admin" />);++ const createButton = screen.getAllByRole("button", { name: /create team/i })[0];+ act(() => {+ fireEvent.click(createButton);+ });++ await waitFor(() => {+ expect(screen.getByLabelText(/team name/i)).toBeInTheDocument();+ });++ fireEvent.change(screen.getByLabelText(/team name/i), { target: { value: "No Org Team" } });+ fireEvent.change(screen.getByTestId("create-team-models-select"), { target: { value: "gpt-4" } });++ const submitButtons = screen.getAllByRole("button", { name: /create team/i });+ fireEvent.click(submitButtons[submitButtons.length - 1]);++ await waitFor(() => {+ expect(teamCreateCall).toHaveBeenCalledWith(+ "test-token",+ expect.objectContaining({ team_alias: "No Org Team", organization_id: null }),+ );+ });+ });+});diff --git a/ui/litellm-dashboard/src/components/OldTeams.tsx b/ui/litellm-dashboard/src/components/OldTeams.tsxindex adfec4bdf6a..be9015e3730 100644--- a/ui/litellm-dashboard/src/components/OldTeams.tsx+++ b/ui/litellm-dashboard/src/components/OldTeams.tsx@@ -262,14 +262,15 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUseruseEffect(() => {if (isTeamModalVisible) {const adminOrgs = getAdminOrganizations(userRole, userID, organizations);+ const isOrgAdmin = userRole !== "Admin";- // If there's exactly one organization the user is admin for, preselect it- if (adminOrgs.length === 1) {+ // Org admins must scope a team to an org, so with exactly one we preselect it.+ // Proxy admins can create org-less teams, so the field stays optional regardless of org count.+ if (isOrgAdmin && adminOrgs.length === 1) {const org = adminOrgs[0];form.setFieldValue("organization_id", org.organization_id);setCurrentOrgForCreateTeam(org);} else {- // Reset the organization selection for multiple orgsform.setFieldValue("organization_id", currentOrg?.organization_id || null);setCurrentOrgForCreateTeam(currentOrg);}@@ -1132,7 +1133,7 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUser: []}help={- isSingleOrg+ isOrgAdmin && isSingleOrg? "You can only create teams within this organization": isOrgAdmin? "required"@@ -1142,7 +1143,7 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUser<SelectshowSearchallowClear={!isOrgAdmin}- disabled={isSingleOrg}+ disabled={isOrgAdmin && isSingleOrg}placeholder={hasNoOrgs ? "No organizations available" : "Search or select an Organization"}onChange={(value) => {form.setFieldValue("organization_id", value);