Skip to content

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]

fix(ui): show pass through route selections and match team id substrings in team search (#35319)

devin-ai-integration[bot]e38df02d8594
diff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.py
index c35c17aa359..fa01f43d049 100644
--- a/litellm/proxy/management_endpoints/team_endpoints.py
+++ b/litellm/proxy/management_endpoints/team_endpoints.py
@@ -131,6 +131,7 @@ from litellm.types.proxy.management_endpoints.team_endpoints import (
BulkUpdateTeamMemberPermissionsRequest,
BulkUpdateTeamMemberPermissionsResponse,
GetTeamMemberPermissionsResponse,
+ TeamIdSearchMatch,
TeamListItem,
TeamListResponse,
TeamMemberAddResult,
@@ -3973,6 +3974,7 @@ async def _build_team_list_where_conditions(
user_id: Optional[str],
use_deleted_table: bool,
search: Optional[str] = None,
+ search_team_id_match: TeamIdSearchMatch = "exact",
org_admin_org_ids: Optional[List[str]] = None,
user_api_key_cache: Optional[Any] = None,
proxy_logging_obj: Optional[Any] = None,
@@ -3996,7 +3998,7 @@ async def _build_team_list_where_conditions(
if search:
where_conditions["OR"] = [
- {"team_id": search},
+ ({"team_id": {"startsWith": search}} if search_team_id_match == "prefix" else {"team_id": search}),
{"team_alias": {"contains": search, "mode": "insensitive"}},
]
@@ -4230,8 +4232,14 @@ async def list_team_v2(
),
search: Optional[str] = fastapi.Query(
default=None,
- description="Combined search: matches teams whose 'team_id' equals the value OR whose 'team_alias' contains it (case-insensitive).",
+ description="Combined search: matches teams whose 'team_id' matches the value OR whose 'team_alias' contains it (case-insensitive).",
),
+ search_team_id_match: Annotated[
+ TeamIdSearchMatch,
+ fastapi.Query(
+ description="How 'search' matches 'team_id': 'exact' (default) or 'prefix' for a case-sensitive prefix match."
+ ),
+ ] = "exact",
page: int = fastapi.Query(default=1, description="Page number for pagination", ge=1),
page_size: int = fastapi.Query(default=10, description="Number of teams per page", ge=1, le=100),
sort_by: Optional[str] = fastapi.Query(
@@ -4308,6 +4316,7 @@ async def list_team_v2(
user_id=user_id,
use_deleted_table=use_deleted_table,
search=search,
+ search_team_id_match=search_team_id_match,
org_admin_org_ids=org_admin_org_ids,
user_api_key_cache=user_api_key_cache,
proxy_logging_obj=proxy_logging_obj,
diff --git a/litellm/types/proxy/management_endpoints/team_endpoints.py b/litellm/types/proxy/management_endpoints/team_endpoints.py
index 0e555535874..2d9387da956 100644
--- a/litellm/types/proxy/management_endpoints/team_endpoints.py
+++ b/litellm/types/proxy/management_endpoints/team_endpoints.py
@@ -1,4 +1,4 @@
-from typing import Any, Dict, List, Optional, Union
+from typing import Any, Dict, List, Literal, Optional, Union
from pydantic import BaseModel
@@ -11,6 +11,8 @@ from litellm.proxy._types import (
Member,
)
+TeamIdSearchMatch = Literal["exact", "prefix"]
+
class GetTeamMemberPermissionsRequest(BaseModel):
"""Request to get the team member permissions for a team"""
diff --git a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py
index a658a4b7353..25a0ff644f8 100644
--- a/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py
+++ b/tests/test_litellm/proxy/management_endpoints/test_team_endpoints.py
@@ -3627,9 +3627,9 @@ async def test_list_team_v2_with_invalid_status():
@pytest.mark.asyncio
async def test_list_team_v2_search_builds_or_clause():
"""
- `search` should be passed as a Prisma OR across team_id (exact) and
- team_alias (case-insensitive contains), so the UI can hit a single
- backend filter with either a UUID or a name fragment.
+ `search` should be passed as a Prisma OR across an exact team_id match and a
+ case-insensitive team_alias contains, so the UI needs one backend filter.
+ Exact id matching is the documented default and must not change.
"""
from unittest.mock import AsyncMock, Mock, patch
@@ -3671,6 +3671,54 @@ async def test_list_team_v2_search_builds_or_clause():
}
+async def test_list_team_v2_search_team_id_match_prefix():
+ """
+ Opting into `search_team_id_match="prefix"` should widen the team_id side of
+ the search OR to an index-friendly prefix match, so the first characters of a
+ team id quoted in a proxy error find the team.
+ """
+ from unittest.mock import AsyncMock, Mock, patch
+
+ from fastapi import Request
+
+ from litellm.proxy._types import LitellmUserRoles, UserAPIKeyAuth
+ from litellm.proxy.management_endpoints.team_endpoints import list_team_v2
+
+ mock_request = Mock(spec=Request)
+ mock_admin = UserAPIKeyAuth(
+ user_role=LitellmUserRoles.PROXY_ADMIN, user_id="admin_user"
+ )
+
+ with patch("litellm.proxy.proxy_server.prisma_client") as mock_prisma_client:
+ mock_db = Mock()
+ mock_prisma_client.db = mock_db
+ mock_db.litellm_teamtable.find_many = AsyncMock(return_value=[])
+ mock_db.litellm_teamtable.count = AsyncMock(return_value=0)
+
+ await list_team_v2(
+ http_request=mock_request,
+ user_id=None,
+ organization_id=None,
+ team_id=None,
+ team_alias=None,
+ search="66c432fa",
+ search_team_id_match="prefix",
+ user_api_key_dict=mock_admin,
+ page=1,
+ page_size=10,
+ status=None,
+ )
+
+ find_many_kwargs = mock_db.litellm_teamtable.find_many.call_args.kwargs
+ assert find_many_kwargs["where"] == {
+ "OR": [
+ {"team_id": {"startsWith": "66c432fa"}},
+ {"team_alias": {"contains": "66c432fa", "mode": "insensitive"}},
+ ]
+ }
+
+
@pytest.mark.asyncio
async def test_list_team_v2_search_composes_with_user_id_filter():
"""
@@ -3724,6 +3772,7 @@ async def test_list_team_v2_search_composes_with_user_id_filter():
team_id=None,
team_alias=None,
search="team_a",
+ search_team_id_match="prefix",
user_api_key_dict=mock_user_api_key_dict,
page=1,
page_size=10,
@@ -3733,7 +3782,7 @@ async def test_list_team_v2_search_composes_with_user_id_filter():
find_many_kwargs = mock_db.litellm_teamtable.find_many.call_args.kwargs
where = find_many_kwargs["where"]
assert where["OR"] == [
- {"team_id": "team_a"},
+ {"team_id": {"startsWith": "team_a"}},
{"team_alias": {"contains": "team_a", "mode": "insensitive"}},
]
assert where["team_id"] == {"in": ["team_a", "team_b"]}
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts
index f532c44ffd7..4061026b94d 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts
+++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/teams/useTeams.ts
@@ -24,6 +24,7 @@ export interface TeamListCallOptions {
teamID?: string | null;
team_alias?: string | null;
search?: string | null;
+ searchTeamIdMatch?: "exact" | "prefix" | null;
userID?: string | null;
sortBy?: string | null;
sortOrder?: string | null;
@@ -48,6 +49,7 @@ export const teamListCall = async (
organization_id: options.organizationID,
team_alias: options.team_alias,
search: options.search,
+ search_team_id_match: options.searchTeamIdMatch,
user_id: options.userID,
page,
page_size: pageSize,
@@ -213,6 +215,7 @@ const deletedTeamListCall = async (
organization_id: options.organizationID,
team_alias: options.team_alias,
search: options.search,
+ search_team_id_match: options.searchTeamIdMatch,
user_id: options.userID,
page,
page_size: pageSize,
diff --git a/ui/litellm-dashboard/src/components/Teams.tsx b/ui/litellm-dashboard/src/components/Teams.tsx
index 0a3c7fc736d..582f75578ed 100644
--- a/ui/litellm-dashboard/src/components/Teams.tsx
+++ b/ui/litellm-dashboard/src/components/Teams.tsx
@@ -957,25 +957,23 @@ const Teams: React.FC<TeamProps> = ({ accessToken, userID, userRole, premiumUser
placeholder="Select vector stores (optional)"
/>
</Form.Item>
- <Form.Item label="Allowed Pass Through Routes" name="allowed_passthrough_routes" className="mt-8">
- <Tooltip
- title={
- !premiumUser
- ? "Premium feature - Upgrade to set allowed pass through routes"
- : !isProxyAdminRole(userRole || "")
- ? "Only proxy admins can set allowed pass through routes"
- : ""
- }
- placement="top"
- >
- <PassThroughRoutesSelector
- onChange={(values: string[]) => form.setFieldValue("allowed_passthrough_routes", values)}
- value={form.getFieldValue("allowed_passthrough_routes")}
- accessToken={accessToken || ""}
- placeholder="Select pass through routes (optional)"
- disabled={!premiumUser || !isProxyAdminRole(userRole || "")}
- />
- </Tooltip>
+ <Form.Item
+ label="Allowed Pass Through Routes"
+ name="allowed_passthrough_routes"
+ className="mt-8"
+ tooltip={
+ !premiumUser
+ ? "Premium feature - Upgrade to set allowed pass through routes"
+ : !isProxyAdminRole(userRole || "")
+ ? "Only proxy admins can set allowed pass through routes"
+ : undefined
+ }
+ >
+ <PassThroughRoutesSelector
+ accessToken={accessToken || ""}
+ placeholder="Select pass through routes (optional)"
+ disabled={!premiumUser || !isProxyAdminRole(userRole || "")}
+ />
</Form.Item>
</AccordionBody>
</Accordion>
diff --git a/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.test.tsx b/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.test.tsx
index 9469be12128..09bd3e9f245 100644
--- a/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.test.tsx
+++ b/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.test.tsx
@@ -196,6 +196,19 @@ describe("server-side filtering maps controls to the right query params", () =>
expect(mockUseTeamsTable).toHaveBeenLastCalledWith(1, 50, expect.objectContaining({ search: "platform" }));
});
});
+
+ it("opts into team id prefix matching so a partial id from a proxy error finds the team", async () => {
+ renderTable();
+ fireEvent.change(screen.getByTestId("datatable-search"), { target: { value: "66c432fa" } });
+
+ await waitFor(() => {
+ expect(mockUseTeamsTable).toHaveBeenLastCalledWith(
+ 1,
+ 50,
+ expect.objectContaining({ search: "66c432fa", searchTeamIdMatch: "prefix" }),
+ );
+ });
+ });
});
describe("non-admin scoping", () => {
diff --git a/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.tsx b/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.tsx
index 3b75db52b16..5f5a6f26c0a 100644
--- a/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.tsx
+++ b/ui/litellm-dashboard/src/components/TeamsPage/TeamsTable.tsx
@@ -66,6 +66,7 @@ export function TeamsTable({ userRole, userID, onSelectTeam, onEditTeam, onDelet
team_alias: getFilterValue("alias"),
teamID: getFilterValue("team_id"),
search: searchQuery.trim() || undefined,
+ searchTeamIdMatch: "prefix" as const,
userID: isAdminView ? undefined : userID ?? undefined,
sortBy: sorting[0]?.id,
sortOrder: toSortOrder(sorting),
diff --git a/ui/litellm-dashboard/src/components/common_components/PassThroughRoutesSelector.tsx b/ui/litellm-dashboard/src/components/common_components/PassThroughRoutesSelector.tsx
index 5cea88b2af2..e02125dea56 100644
--- a/ui/litellm-dashboard/src/components/common_components/PassThroughRoutesSelector.tsx
+++ b/ui/litellm-dashboard/src/components/common_components/PassThroughRoutesSelector.tsx
@@ -3,7 +3,7 @@ import { Select } from "antd";
import { getPassThroughEndpointsCall } from "../networking";
interface PassThroughRoutesSelectorProps {
- onChange: (selectedRoutes: string[]) => void;
+ onChange?: (selectedRoutes: string[]) => void;
value?: string[];
className?: string;
accessToken: string;
diff --git a/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx b/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx
index 711652eb783..00f36f016b7 100644
--- a/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx
+++ b/ui/litellm-dashboard/src/components/organisms/create_key_button.tsx
@@ -1385,8 +1385,6 @@ const CreateKey: React.FC<CreateKeyProps> = ({ team, teams, data, addKey, autoOp
}
>
<PassThroughRoutesSelector
- onChange={(values: string[]) => form.setFieldValue("allowed_passthrough_routes", values)}
- value={form.getFieldValue("allowed_passthrough_routes")}
accessToken={accessToken}
placeholder={
!premiumUser
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
index 25365d26a12..712cff80649 100644
--- a/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.test.tsx
@@ -18,6 +18,7 @@ vi.mock("@/components/networking", () => ({
getTeamPermissionsCall: vi.fn(),
organizationInfoCall: vi.fn(),
getRouterSettingsCall: vi.fn().mockResolvedValue({ fields: [] }),
+ getPassThroughEndpointsCall: vi.fn(),
}));
vi.mock("@/components/utils/dataUtils", () => ({
@@ -1142,4 +1143,54 @@ describe("TeamInfoView", () => {
expect(within(dropdown).getByTitle("opt-in")).toBeInTheDocument();
});
});
+
+ describe("allowed pass through routes", () => {
+ beforeEach(() => {
+ testQueryClient.clear();
+ vi.mocked(networking.teamInfoCall).mockResolvedValue(createMockTeamData({ models: ["gpt-4"] }));
+ vi.mocked(networking.teamUpdateCall).mockResolvedValue({ data: {}, team_id: "123" } as any);
+ vi.mocked(networking.getPassThroughEndpointsCall).mockResolvedValue({
+ endpoints: [{ path: "/bedrock-passthrough", methods: ["POST"] }],
+ });
+ });
+
+ it("should show a route picked from the dropdown in the field and save it", async () => {
+ const user = userEvent.setup({ delay: null });
+
+ renderWithProviders(<TeamInfoView {...defaultProps} premiumUser={true} />);
+
+ await waitFor(() => {
+ expect(screen.queryAllByText("Test Team").length).toBeGreaterThan(0);
+ });
+
+ await user.click(screen.getByRole("tab", { name: "Settings" }));
+ await user.click(await screen.findByRole("button", { name: /edit settings/i }));
+
+ const routesLabel = await screen.findByText("Allowed Pass Through Routes");
+ const routesFormItem = routesLabel.closest(".ant-form-item") as HTMLElement;
+
+ await user.click(within(routesFormItem).getByRole("combobox"));
+
+ const option = await screen.findByTitle("POST /bedrock-passthrough");
+ await user.click(option);
+
+ await waitFor(() => {
+ expect(within(routesFormItem).getByText(/\/bedrock-passthrough/)).toBeInTheDocument();
+ });
+
+ await user.click(screen.getByRole("button", { name: /save changes/i }));
+
+ await waitFor(() => {
+ expect(networking.teamUpdateCall).toHaveBeenCalledWith(
+ "test-token",
+ expect.objectContaining({
+ team_id: "123",
+ metadata: expect.objectContaining({
+ allowed_passthrough_routes: ["/bedrock-passthrough"],
+ }),
+ }),
+ );
+ });
+ });
+ });
});
diff --git a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
index acd5a8966a7..34570043f52 100644
--- a/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
+++ b/ui/litellm-dashboard/src/components/team/TeamInfo.tsx
@@ -1361,25 +1361,22 @@ const TeamInfoView: React.FC<TeamInfoProps> = ({
/>
</Form.Item>
- <Form.Item label="Allowed Pass Through Routes" name="allowed_passthrough_routes">
- <Tooltip
- title={
- !premiumUser
- ? "Premium feature - Upgrade to set allowed pass through routes"
- : !is_proxy_admin
- ? "Only proxy admins can set allowed pass through routes"
- : ""
- }
- placement="top"
- >
- <PassThroughRoutesSelector
- onChange={(values: string[]) => form.setFieldValue("allowed_passthrough_routes", values)}
- value={form.getFieldValue("allowed_passthrough_routes")}
- accessToken={accessToken || ""}
- placeholder="Select pass through routes"
- disabled={!premiumUser || !is_proxy_admin}
- />
- </Tooltip>
+ <Form.Item
+ label="Allowed Pass Through Routes"
+ name="allowed_passthrough_routes"
+ tooltip={
+ !premiumUser
+ ? "Premium feature - Upgrade to set allowed pass through routes"
+ : !is_proxy_admin
+ ? "Only proxy admins can set allowed pass through routes"
+ : undefined
+ }
+ >
+ <PassThroughRoutesSelector
+ accessToken={accessToken || ""}
+ placeholder="Select pass through routes"
+ disabled={!premiumUser || !is_proxy_admin}
+ />
</Form.Item>
<Form.Item label="MCP Servers / Access Groups" name="mcp_servers_and_groups">
diff --git a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
index 962c6bc3568..4b6c266eb8f 100644
--- a/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
+++ b/ui/litellm-dashboard/src/components/templates/key_edit_view.tsx
@@ -689,26 +689,23 @@ export function KeyEditView({
<AccessGroupSelector placeholder="Select access groups (optional)" />
</Form.Item>
- <Form.Item label="Allowed Pass Through Routes" name="allowed_passthrough_routes">
- <Tooltip
- title={!premiumUser ? "Setting allowed pass through routes by key is a premium feature" : ""}
- placement="top"
- >
- <PassThroughRoutesSelector
- onChange={(values: string[]) => form.setFieldValue("allowed_passthrough_routes", values)}
- value={form.getFieldValue("allowed_passthrough_routes")}
- accessToken={accessToken || ""}
- placeholder={
- !premiumUser
- ? "Premium feature - Upgrade to set allowed pass through routes by key"
- : Array.isArray(keyData.metadata?.allowed_passthrough_routes) &&
- keyData.metadata.allowed_passthrough_routes.length > 0
- ? `Current: ${keyData.metadata.allowed_passthrough_routes.join(", ")}`
- : "Select or enter allowed pass through routes"
- }
- disabled={!premiumUser}
- />
- </Tooltip>
+ <Form.Item
+ label="Allowed Pass Through Routes"
+ name="allowed_passthrough_routes"
+ tooltip={!premiumUser ? "Setting allowed pass through routes by key is a premium feature" : undefined}
+ >
+ <PassThroughRoutesSelector
+ accessToken={accessToken || ""}
+ placeholder={
+ !premiumUser
+ ? "Premium feature - Upgrade to set allowed pass through routes by key"
+ : Array.isArray(keyData.metadata?.allowed_passthrough_routes) &&
+ keyData.metadata.allowed_passthrough_routes.length > 0
+ ? `Current: ${keyData.metadata.allowed_passthrough_routes.join(", ")}`
+ : "Select or enter allowed pass through routes"
+ }
+ disabled={!premiumUser}
+ />
</Form.Item>
<Form.Item label="Vector Stores" name="vector_stores">
diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.ts
index 9a301f1c474..109d638fb9c 100644
--- a/ui/litellm-dashboard/src/lib/http/schema.d.ts
+++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts
@@ -58372,8 +58372,10 @@ export interface operations {
team_id?: string | null;
/** @description Only return teams which this 'team_alias' belongs to. Supports partial matching. */
team_alias?: string | null;
- /** @description Combined search: matches teams whose 'team_id' equals the value OR whose 'team_alias' contains it (case-insensitive). */
+ /** @description Combined search: matches teams whose 'team_id' matches the value OR whose 'team_alias' contains it (case-insensitive). */
search?: string | null;
+ /** @description How 'search' matches 'team_id': 'exact' (default) or 'prefix' for a case-sensitive prefix match. */
+ search_team_id_match?: "exact" | "prefix";
/** @description Page number for pagination */
page?: number;
/** @description Number of teams per page */