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]

Key Already Exist Error Notification (#15993)

yuneng-jiang43af45ab88f5
diff --git a/ui/litellm-dashboard/src/components/molecules/notifications_manager.test.tsx b/ui/litellm-dashboard/src/components/molecules/notifications_manager.test.tsx
new file mode 100644
index 00000000000..c57c3052170
--- /dev/null
+++ b/ui/litellm-dashboard/src/components/molecules/notifications_manager.test.tsx
@@ -0,0 +1,41 @@
+import { describe, it, expect, beforeEach, vi } from "vitest";
+import { notification } from "antd";
+import NotificationManager from "./notifications_manager";
+
+// Mock the antd notification module
+vi.mock("antd", () => ({
+ notification: {
+ error: vi.fn(),
+ warning: vi.fn(),
+ info: vi.fn(),
+ success: vi.fn(),
+ destroy: vi.fn(),
+ },
+}));
+
+describe("NotificationManager", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ });
+
+ describe("Already Exists case", () => {
+ it("should show error notification for 'already exists' message", () => {
+ const error = {
+ message: "Key with alias 'test10' already exists.",
+ type: "bad_request_error",
+ code: "400",
+ };
+
+ NotificationManager.fromBackend(error);
+
+ expect(notification.error).toHaveBeenCalledWith(
+ expect.objectContaining({
+ message: "Already Exists",
+ description: "Key with alias 'test10' already exists.",
+ duration: 6,
+ placement: "topRight",
+ }),
+ );
+ });
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/molecules/notifications_manager.tsx b/ui/litellm-dashboard/src/components/molecules/notifications_manager.tsx
index 559fa2e03c8..6c6a0e38f21 100644
--- a/ui/litellm-dashboard/src/components/molecules/notifications_manager.tsx
+++ b/ui/litellm-dashboard/src/components/molecules/notifications_manager.tsx
@@ -317,7 +317,8 @@ const NotificationManager = {
title === "Authentication Error" ||
title === "Access Denied" ||
title === "Not Found" ||
- title === "Error"
+ title === "Error" ||
+ title === "Already Exists"
) {
notification.error({ ...payload, duration: extra?.duration ?? 6 });
return;