diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx
index ef5bb2a037..749396c82f 100644
--- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx
+++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.test.tsx
@@ -542,3 +542,86 @@ it("should display 'Default Proxy Admin' for created_by when value is 'default_u
expect(defaultProxyAdminElements.length).toBeGreaterThan(0);
});
});
+
+
+it("should render table without crashing when models is null", async () => {
+ const keyWithNullModels = {
+ ...mockKey,
+ models: null as unknown as string[],
+ };
+
+ mockUseFilterLogic.mockReturnValue({
+ filters: {
+ "Team ID": "",
+ "Organization ID": "",
+ "Key Alias": "",
+ "User ID": "",
+ "Sort By": "created_at",
+ "Sort Order": "desc",
+ },
+ filteredKeys: [keyWithNullModels],
+ allKeyAliases: ["test-key-alias"],
+ allTeams: [mockTeam],
+ allOrganizations: [mockOrganization],
+ handleFilterChange: vi.fn(),
+ handleFilterReset: vi.fn(),
+ });
+
+ const mockProps = {
+ teams: [mockTeam],
+ organizations: [mockOrganization],
+ onSortChange: vi.fn(),
+ currentSort: {
+ sortBy: "created_at",
+ sortOrder: "desc" as const,
+ },
+ };
+
+ // This should not throw an error
+ renderWithProviders();
+
+ await waitFor(() => {
+ expect(screen.getByText("Test Key Alias")).toBeInTheDocument();
+ });
+});
+
+it("should render table without crashing when models is undefined", async () => {
+ const keyWithUndefinedModels = {
+ ...mockKey,
+ models: undefined as unknown as string[],
+ };
+
+ mockUseFilterLogic.mockReturnValue({
+ filters: {
+ "Team ID": "",
+ "Organization ID": "",
+ "Key Alias": "",
+ "User ID": "",
+ "Sort By": "created_at",
+ "Sort Order": "desc",
+ },
+ filteredKeys: [keyWithUndefinedModels],
+ allKeyAliases: ["test-key-alias"],
+ allTeams: [mockTeam],
+ allOrganizations: [mockOrganization],
+ handleFilterChange: vi.fn(),
+ handleFilterReset: vi.fn(),
+ });
+
+ const mockProps = {
+ teams: [mockTeam],
+ organizations: [mockOrganization],
+ onSortChange: vi.fn(),
+ currentSort: {
+ sortBy: "created_at",
+ sortOrder: "desc" as const,
+ },
+ };
+
+ // This should not throw an error
+ renderWithProviders();
+
+ await waitFor(() => {
+ expect(screen.getByText("Test Key Alias")).toBeInTheDocument();
+ });
+});
diff --git a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx
index 465b9b8fbe..f7c47943e7 100644
--- a/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx
+++ b/ui/litellm-dashboard/src/components/VirtualKeysPage/VirtualKeysTable.tsx
@@ -727,7 +727,7 @@ export function VirtualKeysTable({ teams, organizations, onSortChange, currentSo
whiteSpace: "pre-wrap",
overflow: "hidden",
}}
- className={`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${cell.column.id === "models" && (cell.getValue() as string[]).length > 3 ? "px-0" : ""}`}
+ className={`py-0.5 max-h-8 overflow-hidden text-ellipsis whitespace-nowrap ${cell.column.id === "models" && Array.isArray(cell.getValue()) && (cell.getValue() as string[]).length > 3 ? "px-0" : ""}`}
>
{flexRender(cell.column.columnDef.cell, cell.getContext())}