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 all teams in policy attachment form for admins (#33628)

ryan-crabbe-berri07656cf80b87
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
index 6788e97d25d..fca487df14e 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.test.tsx
@@ -18,6 +18,10 @@ vi.mock("./impact_preview_alert", () => ({
React.createElement("div", { "data-testid": "impact-preview" }, `${impactResult.affected_keys_count} keys`),
}));
+vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({
+ default: () => ({ userId: "admin-user-id", userRole: "Admin", accessToken: "test-token" }),
+}));
+
const makePolicy = (overrides: Partial<Policy> = {}): Policy => ({
policy_id: "policy-id-1",
policy_name: "test-policy",
@@ -71,6 +75,12 @@ describe("AddAttachmentForm", () => {
});
});
+ it("fetches all teams, not just teams the caller is a member of (LIT-4199)", async () => {
+ renderWithProviders(<AddAttachmentForm {...defaultProps} />);
+ await waitFor(() => expect(networking.teamListCall).toHaveBeenCalled());
+ expect(networking.teamListCall).toHaveBeenCalledWith("test-token", null, null);
+ });
+
it("should not fetch teams, keys, or models when accessToken is null", () => {
renderWithProviders(<AddAttachmentForm {...defaultProps} accessToken={null} />);
expect(networking.teamListCall).not.toHaveBeenCalled();
diff --git a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx
index 57203e9ccce..635d734555d 100644
--- a/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx
+++ b/ui/litellm-dashboard/src/app/(dashboard)/policies/_components/add_attachment_form.tsx
@@ -56,7 +56,7 @@ const AddAttachmentForm: React.FC<AddAttachmentFormProps> = ({
setIsLoadingTeams(true);
setTeamsLoaded(false);
try {
- const teamsResponse = await teamListCall(accessToken, null, userId);
+ const teamsResponse = await teamListCall(accessToken, null, null);
const teamsArray = Array.isArray(teamsResponse) ? teamsResponse : teamsResponse?.data || [];
const teamAliases = teamsArray.map((t: any) => t.team_alias).filter(Boolean);
setAvailableTeams(teamAliases);