From 485ceda428ae790800ba21c14cb272d51f07efde Mon Sep 17 00:00:00 2001 From: Patrick Ribbsaeter Date: Tue, 11 Aug 2026 18:54:21 +0200 Subject: [PATCH] fix: preserve custom route display state --- .../src/components/templates/keyEditFieldNormalizers.ts | 6 ++---- .../src/components/templates/key_edit_view.test.tsx | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.ts b/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.ts index 97e4bfb47a4..3e4e271c19f 100644 --- a/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.ts +++ b/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.ts @@ -22,9 +22,8 @@ export const exactKeyTypePresetFromRoutes = (allowedRoutes: string[] | null | un return KEY_TYPE_BY_PRESET_ROUTE[allowedRoutes[0]]; }; -// Determine the key_type display value from allowed_routes -export const keyTypeFromRoutes = (allowedRoutes: string[] | null | undefined): string => - exactKeyTypePresetFromRoutes(allowedRoutes) ?? "default"; +export const keyTypeFromRoutes = (allowedRoutes: string[] | null | undefined): string | undefined => + exactKeyTypePresetFromRoutes(allowedRoutes); export const parseAllowedRoutes = (value: unknown): string[] => typeof value === "string" && value.trim() !== "" @@ -51,4 +50,3 @@ export const currentValuePlaceholder = ( if (!premiumUser) return premiumHint; return Array.isArray(current) && current.length > 0 ? `Current: ${current.join(", ")}` : emptyHint; }; - diff --git a/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx index 373a8983639..5938256f070 100644 --- a/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx +++ b/ui/litellm-dashboard/src/components/templates/key_edit_view.test.tsx @@ -11,6 +11,7 @@ import { modelAvailableCall, vectorStoreListCall, } from "../networking"; +import { keyTypeFromRoutes } from "./keyEditFieldNormalizers"; import { KeyEditView } from "./key_edit_view"; const can = vi.fn(); @@ -135,6 +136,12 @@ vi.mock("../agent_management/AgentSelector", () => ({ ), })); +describe("keyTypeFromRoutes", () => { + it("does not label a mixed allowlist as Full Access", () => { + expect(keyTypeFromRoutes(["llm_api_routes", "/custom"])).toBeUndefined(); + }); +}); + vi.mock("../common_components/AccessGroupSelector", () => ({ default: ({ value = [], onChange }: { value?: string[]; onChange?: (v: string[]) => void }) => (