From 21ea4f90f309d6e9d07999fa5a94c37385614740 Mon Sep 17 00:00:00 2001 From: Tin Chi Lo Date: Fri, 12 Jun 2026 17:59:22 -0700 Subject: [PATCH] fix(ui/mcp): refresh parent on OAuth token persist failure during server edit The server config is already saved by updateMCPServer when the subsequent per-user token persist throws, so returning early without onSuccess(updated) left the edit form open and the parent list stale despite a committed change. Call onSuccess(updated) before returning so the UI matches DB state; the warning toast still replaces the success toast. --- .../src/components/mcp_tools/mcp_server_edit.test.tsx | 4 ++-- .../src/components/mcp_tools/mcp_server_edit.tsx | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx index d7c1241b044..abcde7dab09 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.test.tsx @@ -846,7 +846,7 @@ describe("MCPServerEdit (OAuth token persistence on save)", () => { expect(mockSetToken).not.toHaveBeenCalled(); }); - it("does not show success when OBO token persistence fails after update", async () => { + it("warns but still refreshes the parent via onSuccess when OBO token persistence fails after update", async () => { mockOauth.tokenResponse = { access_token: "obo-tok", refresh_token: "obo-refresh", @@ -879,7 +879,7 @@ describe("MCPServerEdit (OAuth token persistence on save)", () => { "MCP Server updated, but failed to persist OAuth token: write failed", ); expect(NotificationsManager.success).not.toHaveBeenCalledWith("MCP Server updated successfully"); - expect(onSuccess).not.toHaveBeenCalled(); + expect(onSuccess).toHaveBeenCalledWith(expect.objectContaining({ server_id: interactiveOAuthServer.server_id })); }); it("persists the passthrough token to sessionStorage on save after authorize", async () => { diff --git a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx index b992313d4a8..74eb16b12c9 100644 --- a/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx +++ b/ui/litellm-dashboard/src/components/mcp_tools/mcp_server_edit.tsx @@ -713,6 +713,7 @@ const MCPServerEdit: React.FC = ({ NotificationsManager.fromBackend( "MCP Server updated, but failed to persist OAuth token" + (message ? `: ${message}` : ""), ); + onSuccess(updated); return; } }