Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ui/litellm-dashboard/eslint-metrics.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@typescript-eslint/no-explicit-any": 2026,
"complexity": 128,
"@typescript-eslint/no-explicit-any": 2016,
"complexity": 127,
"max-depth": 61
}
14 changes: 0 additions & 14 deletions ui/litellm-dashboard/eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1133,20 +1133,6 @@
"count": 1
}
},
"src/components/key_team_helpers/filter_logic.tsx": {
"react-hooks/purity": {
"count": 1
},
"react-hooks/refs": {
"count": 1
},
"react-hooks/set-state-in-effect": {
"count": 3
},
"react-hooks/use-memo": {
"count": 1
}
},
"src/components/key_team_helpers/key_list.tsx": {
"react-hooks/set-state-in-effect": {
"count": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ vi.mock("@/app/(dashboard)/hooks/teams/useTeams", () => ({
teamListCall: vi.fn(() => new Promise(() => {})),
}));

vi.mock("@/components/organizations", () => ({
fetchOrganizations: vi.fn(),
}));

vi.mock("next/navigation", () => ({
useSearchParams: () => new URLSearchParams(""),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import { teamListCall as v2TeamListCall } from "@/app/(dashboard)/hooks/teams/useTeams";
import useAuthorized from "@/app/(dashboard)/hooks/useAuthorized";
import { KeyResponse, Team } from "@/components/key_team_helpers/key_list";
import { Organization } from "@/components/networking";
import { CreateKeyPrefillData } from "@/components/organisms/create_key_button";
import { fetchOrganizations } from "@/components/organizations";
import UserDashboard from "@/components/user_dashboard";
import { useAuth } from "@/contexts/AuthContext";
import { useSearchParams } from "next/navigation";
Expand All @@ -20,7 +18,6 @@ export default function ApiKeysDashboard() {

const [teams, setTeams] = useState<Team[] | null>(null);
const [keys, setKeys] = useState<KeyResponse[] | null>([]);
const [organizations, setOrganizations] = useState<Organization[]>([]);
const [createClicked, setCreateClicked] = useState<boolean>(false);

const autoOpenCreate = searchParams.get("create") === "true";
Expand Down Expand Up @@ -77,9 +74,6 @@ export default function ApiKeysDashboard() {
.then((response) => setTeams(response.teams ?? []))
.catch(console.error);
}
if (accessToken) {
fetchOrganizations(accessToken, setOrganizations);
}
}, [accessToken, userID, userRole]);

return (
Expand All @@ -94,7 +88,6 @@ export default function ApiKeysDashboard() {
setUserEmail={setUserEmail}
setTeams={setTeams}
setKeys={setKeys}
organizations={organizations}
addKey={addKey}
createClicked={createClicked}
autoOpenCreate={autoOpenCreate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
vi.mock("@/components/networking", () => ({
getProxyBaseUrl: vi.fn().mockReturnValue(""),
getGlobalLitellmHeaderName: vi.fn().mockReturnValue("Authorization"),
deriveErrorMessage: vi.fn((errorData: any) => {

Check warning on line 12 in ui/litellm-dashboard/src/app/(dashboard)/hooks/keys/useKeys.test.ts

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
return (
(errorData?.error && (errorData.error.message || errorData.error)) ||
errorData?.message ||
Expand Down Expand Up @@ -69,6 +69,7 @@
organization_id: null,
created_at: "2024-01-01T00:00:00Z",
updated_at: "2024-01-01T00:00:00Z",
last_active: null,
team_spend: 0,
team_alias: "",
team_tpm_limit: 0,
Expand Down Expand Up @@ -125,6 +126,7 @@
organization_id: null,
created_at: "2024-01-01T00:00:00Z",
updated_at: "2024-01-01T00:00:00Z",
last_active: null,
team_spend: 0,
team_alias: "test-team",
team_tpm_limit: 1000,
Expand Down Expand Up @@ -460,6 +462,31 @@
expect(callUrl).not.toContain("project_id");
});

// LIT-4080 guard: filter options must be part of the query key, not just the
// queryFn closure. If they were dropped from the key, changing a filter would
// reuse the cached (unfiltered) result and never refetch — exactly the bug
// where deleting a key wiped the active User ID filter.
it("refetches with the new filter when a filter option changes (options are in the query key)", async () => {
mockFetch.mockResolvedValue({
ok: true,
json: async () => mockKeysResponse,
});

const { result, rerender } = renderHook(({ userID }) => useKeys(1, 10, { userID }), {
wrapper,
initialProps: { userID: "user-1" },
});

await waitFor(() => expect(result.current.isLoading).toBe(false));
expect(mockFetch).toHaveBeenCalledTimes(1);
expect(mockFetch.mock.calls[0][0]).toContain("user_id=user-1");

rerender({ userID: "user-2" });

await waitFor(() => expect(mockFetch).toHaveBeenCalledTimes(2));
expect(mockFetch.mock.calls[1][0]).toContain("user_id=user-2");
});

it("should pass agentID filter to the API", async () => {
mockFetch.mockResolvedValueOnce({
ok: true,
Expand Down
8 changes: 1 addition & 7 deletions ui/litellm-dashboard/src/app/(dashboard)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import { teamListCall as v2TeamListCall } from "@/app/(dashboard)/hooks/teams/useTeams";
import LoadingScreen from "@/components/common_components/LoadingScreen";
import { Team } from "@/components/key_team_helpers/key_list";
import { Organization, proxyBaseUrl } from "@/components/networking";
import { fetchOrganizations } from "@/components/organizations";
import { proxyBaseUrl } from "@/components/networking";
import UserDashboard from "@/components/user_dashboard";
import { useAuth } from "@/contexts/AuthContext";
import {
Expand All @@ -24,8 +23,7 @@
useAuth();

const [teams, setTeams] = useState<Team[] | null>(null);
const [keys, setKeys] = useState<null | any[]>([]);

Check warning on line 26 in ui/litellm-dashboard/src/app/(dashboard)/page.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
const [organizations, setOrganizations] = useState<Organization[]>([]);

const router = useRouter();
const searchParams = useSearchParams()!;
Expand All @@ -39,7 +37,7 @@
// Track if we've already attempted a return URL redirect to prevent race conditions
const hasAttemptedReturnRedirectRef = useRef(false);

const addKey = (data: any) => {

Check warning on line 40 in ui/litellm-dashboard/src/app/(dashboard)/page.tsx

View workflow job for this annotation

GitHub Actions / frontend-lint

Unexpected any. Specify a different type
setKeys((prevData) => (prevData ? [...prevData, data] : [data]));
setCreateClicked(() => !createClicked);
};
Expand Down Expand Up @@ -112,9 +110,6 @@
.then((response) => setTeams(response.teams ?? []))
.catch(console.error);
}
if (accessToken) {
fetchOrganizations(accessToken, setOrganizations);
}
}, [accessToken, userID, userRole]);

if (authLoading || redirectToLogin || isLegacyRedirect) {
Expand All @@ -135,7 +130,6 @@
setUserEmail={setUserEmail}
setTeams={setTeams}
setKeys={setKeys}
organizations={organizations}
addKey={addKey}
createClicked={createClicked}
/>
Expand Down
Loading
Loading