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): trim and drop blank tags moved out of key metadata JSON
ryan52a3b0ede712
diff --git a/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.test.ts b/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.test.tsindex 9ae0cbee589..9223cc6dbc8 100644--- a/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.test.ts+++ b/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.test.ts@@ -19,6 +19,14 @@ describe("moveTagsOutOfMetadataJson", () => {});});+ it("trims whitespace and drops blank entries the same way the Tags control does", () => {+ expect(moveTagsOutOfMetadataJson('{"tags": [" a ", "a", " ", "", " ui-tag"]}', ["ui-tag"])).toEqual({+ metadata: "{}",+ tags: ["ui-tag", "a"],+ movedTags: ["a"],+ });+ });+it("strips an empty tags array while moving nothing", () => {expect(moveTagsOutOfMetadataJson('{"tags": []}', undefined)).toEqual({metadata: "{}",diff --git a/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.ts b/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.tsindex 208b7c033ac..1cfd1ae35f7 100644--- a/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.ts+++ b/ui/litellm-dashboard/src/components/templates/keyEditFieldNormalizers.ts@@ -60,10 +60,10 @@ export const moveTagsOutOfMetadataJson = (const { tags: metadataTags, ...rest } = parsed;if (!Array.isArray(metadataTags)) return null;const existing = currentTags ?? [];- const movedTags = metadataTags.filter(- (tag: unknown, index: number): tag is string =>- typeof tag === "string" && !existing.includes(tag) && metadataTags.indexOf(tag) === index,- );+ const movedTags = metadataTags+ .filter((tag: unknown): tag is string => typeof tag === "string")+ .map((tag) => tag.trim())+ .filter((tag, index, all) => tag.length > 0 && !existing.includes(tag) && all.indexOf(tag) === index);return { metadata: JSON.stringify(rest, null, 2), tags: [...existing, ...movedTags], movedTags };};