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
Fall back to top-level keyData when resolving previous premium value
Yuneng Jiangcae8b74b0b13
diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsxindex 6b5732436a4..724c961bbdc 100644--- a/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.test.tsx@@ -757,5 +757,24 @@ describe("KeyInfoView", () => {expect.objectContaining({ policies: [] }),);});++ it("should keep an empty policies field when the previous value lives only at the top level of keyData", async () => {+ // Defensive: some premium fields may be present at the top level but not+ // mirrored into metadata. A genuine clear must still be forwarded.+ const keyData: KeyResponse = {+ ...MOCK_KEY_DATA,+ user_id: "proxy-admin-user",+ metadata: {},+ policies: ["existing-policy"],+ } as KeyResponse;++ await enterEditMode(keyData);+ await editViewMocks.onSubmit!({ key: keyData.token, token: keyData.token, policies: [] });++ expect(keyUpdateCall).toHaveBeenCalledWith(+ expect.anything(),+ expect.objectContaining({ policies: [] }),+ );+ });});});diff --git a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx b/ui/litellm-dashboard/src/components/templates/key_info_view.tsxindex bdb8254c726..492e43cbc81 100644--- a/ui/litellm-dashboard/src/components/templates/key_info_view.tsx+++ b/ui/litellm-dashboard/src/components/templates/key_info_view.tsx@@ -166,7 +166,9 @@ export default function KeyInfoView({// state; without this, the next save resends `[]` and trips the premium// gate in prepare_metadata_fields for non-premium users.for (const field of PREMIUM_METADATA_FIELDS) {- const previousValue = (currentKeyData.metadata as Record<string, unknown> | undefined)?.[field];+ const previousValue =+ (currentKeyData.metadata as Record<string, unknown> | undefined)?.[field] ??+ (currentKeyData as unknown as Record<string, unknown>)[field];if (isEmptyValue(formValues[field]) && isEmptyValue(previousValue)) {delete formValues[field];}