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 logs page showing unfiltered results when filter matches zero rows

Ryan Crabbe12a55a8a6f8f
diff --git a/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx b/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx
index 4e7153b64cd..a4dd05b46e7 100644
--- a/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx
+++ b/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx
@@ -69,13 +69,7 @@ export function useLogFilterLogic({
);
const [filters, setFilters] = useState<LogFilterState>(defaultFilters);
- const [backendFilteredLogs, setBackendFilteredLogs] = useState<PaginatedResponse>({
- data: [],
- total: 0,
- page: 1,
- page_size: 50,
- total_pages: 0,
- });
+ const [backendFilteredLogs, setBackendFilteredLogs] = useState<PaginatedResponse | null>(null);
const lastSearchTimestamp = useRef(0);
const performSearch = useCallback(
async (filters: LogFilterState, page = 1) => {
@@ -227,22 +221,23 @@ export function useLogFilterLogic({
// Choose which filtered logs to expose: backend result when active, otherwise client-derived
const filteredLogs: PaginatedResponse = useMemo(() => {
if (hasBackendFilters) {
- // Prefer backend result if present; otherwise fall back to latest logs
- if (backendFilteredLogs && backendFilteredLogs.data) {
+ // When backend filters are active, only show backend results.
+ // If search hasn't completed yet (null), show empty state rather than
+ // falling back to unfiltered logs — that caused filtered views to
+ // display mismatched data when the filter matched zero rows.
+ if (backendFilteredLogs !== null) {
return backendFilteredLogs;
}
- return (
- logs || {
- data: [],
- total: 0,
- page: 1,
- page_size: 50,
- total_pages: 0,
- }
- );
+ return {
+ data: [],
+ total: 0,
+ page: 1,
+ page_size: 50,
+ total_pages: 0,
+ };
}
return clientDerivedFilteredLogs;
- }, [hasBackendFilters, backendFilteredLogs, clientDerivedFilteredLogs, logs]);
+ }, [hasBackendFilters, backendFilteredLogs, clientDerivedFilteredLogs]);
// Fetch all teams and users for potential filter dropdowns (optional, can be adapted)
const { data: allTeams } = useQuery<Team[], Error>({
@@ -284,13 +279,7 @@ export function useLogFilterLogic({
setFilters(defaultFilters);
// Clear backend filtered logs to ensure fresh render
- setBackendFilteredLogs({
- data: [],
- total: 0,
- page: 1,
- page_size: 50,
- total_pages: 0,
- });
+ setBackendFilteredLogs(null);
// Reset selections
debouncedSearch(defaultFilters, 1);