diff --git a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx
index f6c2c873d85..27b2e3fcc94 100644
--- a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx
+++ b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.test.tsx
@@ -94,16 +94,15 @@ describe("CreatedKeyDisplay", () => {
expect(screen.getByRole("button", { name: /copy share link/i })).toBeInTheDocument();
});
- it("should not display a share link when the share call fails", async () => {
+ it("should surface an error and show no link when the share call fails", async () => {
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
vi.mocked(keyShareCreateCall).mockRejectedValue(new Error("boom"));
- const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});
render();
await user.click(screen.getByRole("button", { name: /securely share/i }));
expect(keyShareCreateCall).toHaveBeenCalled();
+ expect(vi.mocked(MessageManager.error)).toHaveBeenCalledWith("Failed to create secure share link. boom");
expect(screen.queryByRole("button", { name: /copy share link/i })).not.toBeInTheDocument();
- consoleError.mockRestore();
});
});
diff --git a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx
index 02bfea1fd0a..512a5f8793a 100644
--- a/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx
+++ b/ui/litellm-dashboard/src/components/shared/CreatedKeyDisplay.tsx
@@ -42,7 +42,8 @@ const CreatedKeyDisplay: React.FC = ({ apiKey, accessTok
setShareLink(response.share_link);
MessageManager.success("Secure share link created");
} catch (error) {
- console.error("Failed to create secure share link:", error);
+ const detail = error instanceof Error ? error.message : "Please try again.";
+ MessageManager.error(`Failed to create secure share link. ${detail}`);
} finally {
setSharing(false);
}