From 2de065929ccc2c9c76e2910d0d5da06453a9cdbb Mon Sep 17 00:00:00 2001 From: chelsealong Date: Wed, 19 Aug 2026 01:47:38 +0000 Subject: [PATCH] fix(ui): stop truncating the test connection error toast handleTestConnection cut caught errors to 100 chars before showing them, so a provider error like Bedrock's access_denied payload was chopped down to its first two words with no way to see the rest. Use toast.fromError, the app's existing helper for surfacing full error text with a derived title, instead of a manual truncate + prefix. --- .../src/components/model_info_view.test.tsx | 23 ++++++++++++++++++- .../src/components/model_info_view.tsx | 7 +----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ui/litellm-dashboard/src/components/model_info_view.test.tsx b/ui/litellm-dashboard/src/components/model_info_view.test.tsx index 4ff9b96a5b9..52403d9abdb 100644 --- a/ui/litellm-dashboard/src/components/model_info_view.test.tsx +++ b/ui/litellm-dashboard/src/components/model_info_view.test.tsx @@ -302,7 +302,28 @@ describe("ModelInfoView", () => { await user.click(testButton); await waitFor(() => { - expect(mockToast.error).toHaveBeenCalled(); + expect(mockToast.fromError).toHaveBeenCalled(); + }); + }); + + it("should not truncate the connection test error message", async () => { + // Regression test: the error toast used to cut the message to 100 chars + // via truncateString, hiding the actual provider error from the user. + const user = userEvent.setup(); + const longMessage = "Bedrock_mantleException - " + "x".repeat(150); + mockTestConnectionRequest.mockRejectedValue(new Error(longMessage)); + + render(, { wrapper }); + + await waitFor(() => { + expect(screen.getByText("Model Settings")).toBeInTheDocument(); + }); + + const testButton = screen.getByRole("button", { name: /test connection/i }); + await user.click(testButton); + + await waitFor(() => { + expect(mockToast.fromError).toHaveBeenCalledWith(expect.stringContaining(longMessage)); }); }); diff --git a/ui/litellm-dashboard/src/components/model_info_view.tsx b/ui/litellm-dashboard/src/components/model_info_view.tsx index ec804ee889b..df7be06fc5c 100644 --- a/ui/litellm-dashboard/src/components/model_info_view.tsx +++ b/ui/litellm-dashboard/src/components/model_info_view.tsx @@ -14,7 +14,6 @@ import { ArrowLeft, CheckIcon, CopyIcon } from "lucide-react"; import { useEffect, useMemo, useState } from "react"; import { copyToClipboard as utilCopyToClipboard } from "../utils/dataUtils"; import { stripMaskedSecrets } from "../utils/maskedSecretUtils"; -import { truncateString } from "../utils/textUtils"; import AutoRouterConnectionTest from "./add_model/auto_router_connection_test"; import { AutoRouterTestTarget, buildAutoRouterTestTargets } from "./add_model/build_auto_router_test_targets"; import { normalizeTierModels, resolveComplexityDefaultModel } from "./add_model/complexity_router_tiers"; @@ -530,11 +529,7 @@ export default function ModelInfoView({ throw new Error(response?.result?.error || response?.message || "Unknown error"); } } catch (error) { - if (error instanceof Error) { - toast.error("Error testing connection: " + truncateString(error.message, 100)); - } else { - toast.error("Error testing connection: " + String(error)); - } + toast.fromError("Error testing connection: " + (error instanceof Error ? error.message : String(error))); } };