Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Normalize empty/non-array chat session payloads at the source (#1149)
rcourtman2aec9338974d
diff --git a/frontend-modern/src/api/__tests__/aiChat.test.ts b/frontend-modern/src/api/__tests__/aiChat.test.tsindex 7f70313ffd..1c47c5de1a 100644--- a/frontend-modern/src/api/__tests__/aiChat.test.ts+++ b/frontend-modern/src/api/__tests__/aiChat.test.ts@@ -59,6 +59,16 @@ describe('AIChatAPI', () => {expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/ai/sessions');});+ it('normalizes a null sessions payload to an empty array (#1149)', async () => {+ apiFetchJSONMock.mockResolvedValueOnce(null);+ await expect(AIChatAPI.listSessions()).resolves.toEqual([]);+ });++ it('normalizes a non-array sessions payload to an empty array (#1149)', async () => {+ apiFetchJSONMock.mockResolvedValueOnce({ error: 'boom' });+ await expect(AIChatAPI.listSessions()).resolves.toEqual([]);+ });+it('clears read timeout timers when chat stream reads complete', async () => {const read = vi.fn().mockResolvedValueOnce({ done: true, value: undefined });const releaseLock = vi.fn();diff --git a/frontend-modern/src/api/aiChat.ts b/frontend-modern/src/api/aiChat.tsindex 9cfdc58876..91503ab5d6 100644--- a/frontend-modern/src/api/aiChat.ts+++ b/frontend-modern/src/api/aiChat.ts@@ -155,9 +155,12 @@ export class AIChatAPI {return apiFetchJSON(`${this.baseUrl}/status`) as Promise<AIStatus>;}- // List all chat sessions+ // List all chat sessions. Normalizes a null/non-array payload (e.g. a server+ // error body) to an empty array so callers can rely on array semantics and do+ // not crash on .length/.some()/.map() (#1149).static async listSessions(): Promise<ChatSession[]> {- return apiFetchJSON(`${this.baseUrl}/sessions`) as Promise<ChatSession[]>;+ const value = await apiFetchJSON(`${this.baseUrl}/sessions`);+ return Array.isArray(value) ? (value as ChatSession[]) : [];}// Create a new session