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]

fix(ui): tolerate malformed persisted hide-health-checks value

mateo-berri19a1d5c4c6e8
diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx
index 593bebdbdae..22e3f635b50 100644
--- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.test.tsx
@@ -461,6 +461,15 @@ describe("RequestLogsPanel", () => {
expect(lastCall()?.params?.exclude_internal_health_checks).toBe(true);
expect(toggle()).toBeChecked();
});
+
+ it("falls back to showing health checks when the persisted value is malformed", async () => {
+ sessionStorage.setItem("excludeInternalHealthChecks", "{not json");
+ renderPanel();
+
+ await waitFor(() => expect(uiSpendLogsCall).toHaveBeenCalled());
+ expect(lastCall()?.params?.exclude_internal_health_checks).toBe(false);
+ expect(toggle()).not.toBeChecked();
+ });
});
describe("live tail", () => {
diff --git a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx
index 4e424904d40..52ea78abf5e 100644
--- a/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/RequestLogsPanel.tsx
@@ -72,10 +72,9 @@ export default function RequestLogsPanel({ accessToken, token, userRole, userID,
sessionStorage.setItem("isLiveTail", JSON.stringify(isLiveTail));
}, [isLiveTail]);
- const [excludeInternalHealthChecks, setExcludeInternalHealthChecks] = useState<boolean>(() => {
- const storedValue = sessionStorage.getItem("excludeInternalHealthChecks");
- return storedValue !== null ? JSON.parse(storedValue) : false;
- });
+ const [excludeInternalHealthChecks, setExcludeInternalHealthChecks] = useState<boolean>(
+ () => sessionStorage.getItem("excludeInternalHealthChecks") === "true",
+ );
useEffect(() => {
sessionStorage.setItem("excludeInternalHealthChecks", JSON.stringify(excludeInternalHealthChecks));