From 51ed234e36d46eb33a298337e37511fc7133a90d Mon Sep 17 00:00:00 2001 From: Yuneng Jiang Date: Wed, 13 May 2026 20:20:55 -0700 Subject: [PATCH] fix(ui): disable retries on readiness/details + cover token forwarding Two small follow-ups on the readiness/details migration: - Set `retry: false` on the query. The payload feeds a passive navbar tag and a debug banner; a 401 from an expired token shouldn't fan out into three retries against the proxy. - Add navbar specs that assert the `accessToken` prop is forwarded into the hook (matches the DebugWarningBanner spec). Without this, the navbar could silently regress to passing `undefined` and the existing tests wouldn't catch it. --- .../useHealthReadinessDetails.ts | 3 +++ .../src/components/navbar.test.tsx | 23 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/ui/litellm-dashboard/src/app/(dashboard)/hooks/healthReadiness/useHealthReadinessDetails.ts b/ui/litellm-dashboard/src/app/(dashboard)/hooks/healthReadiness/useHealthReadinessDetails.ts index f89858bc0e9..5838dbd0ee6 100644 --- a/ui/litellm-dashboard/src/app/(dashboard)/hooks/healthReadiness/useHealthReadinessDetails.ts +++ b/ui/litellm-dashboard/src/app/(dashboard)/hooks/healthReadiness/useHealthReadinessDetails.ts @@ -54,5 +54,8 @@ export const useHealthReadinessDetails = ( queryFn: () => fetchHealthReadinessDetails(accessToken!), enabled: Boolean(accessToken), staleTime: 5 * 60 * 1000, + // The response feeds a passive navbar tag and a debug banner — a failed + // call (e.g. expired token → 401) shouldn't fan out into three retries. + retry: false, }); }; diff --git a/ui/litellm-dashboard/src/components/navbar.test.tsx b/ui/litellm-dashboard/src/components/navbar.test.tsx index d2f3465d015..2e122164969 100644 --- a/ui/litellm-dashboard/src/components/navbar.test.tsx +++ b/ui/litellm-dashboard/src/components/navbar.test.tsx @@ -99,12 +99,17 @@ let mockUseAuthorizedImpl = () => ({ premiumUser: false, }); +const useHealthReadinessDetailsSpy = vi.hoisted(() => vi.fn()); + vi.mock("@/contexts/ThemeContext", () => ({ useTheme: () => mockUseThemeImpl(), })); vi.mock("@/app/(dashboard)/hooks/healthReadiness/useHealthReadinessDetails", () => ({ - useHealthReadinessDetails: () => mockUseHealthReadinessDetailsImpl(), + useHealthReadinessDetails: (accessToken: string | null | undefined) => { + useHealthReadinessDetailsSpy(accessToken); + return mockUseHealthReadinessDetailsImpl(); + }, })); vi.mock("@/app/(dashboard)/hooks/useAuthorized", () => ({ @@ -214,6 +219,22 @@ describe("Navbar", () => { mockUseHealthReadinessDetailsImpl = () => ({ data: null }); }); + it("should forward accessToken to the readiness hook", () => { + useHealthReadinessDetailsSpy.mockClear(); + + renderWithProviders(); + + expect(useHealthReadinessDetailsSpy).toHaveBeenCalledWith("my-token"); + }); + + it("should forward a null accessToken to the readiness hook (disables the hook)", () => { + useHealthReadinessDetailsSpy.mockClear(); + + renderWithProviders(); + + expect(useHealthReadinessDetailsSpy).toHaveBeenCalledWith(null); + }); + it("should use custom logo from theme context", () => { mockUseThemeImpl = () => ({ logoUrl: "https://example.com/custom-logo.png" });