Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

Reject ambiguous backup inventory identities

pulse-triage[bot]5020a6e6c1bd
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 63394cbbbc..efec0a3ea4 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -21,6 +21,25 @@
## Purpose
+### Backup inventory identities must be unambiguous
+
+Each PVE task, archive and guest-snapshot collection, and the PBS snapshot
+collection, requires unique exact record IDs. Identical repeats inflate counts;
+conflicting repeats share disclosure state and cannot select a trustworthy
+record. Reject the entire source read through the existing format-error path,
+without deduplication, partial acceptance or invented IDs. Preserve warned
+previously accepted evidence and independent sources until a valid retry;
+scope/access withdrawal remains unchanged. IDs stay opaque, with independent
+collection namespaces. Valid empty/nil collections, policy, provider and guest
+operations are unchanged.
+
+Normal-suite `proxmoxBackupInventory.test.ts` checks identical/conflicting IDs
+in all four collections and distinct-ID controls. `ProxmoxBackupsTable.test.tsx`
+checks initial and refresh rejection, retained details/counts, independent
+sources, isolated retry and recurrence through the consuming page. Browser
+proof must exercise the real HTTP reader and desktop/narrow interactions and
+pixels. This establishes inspection safety, not native guest or backup recovery.
+
### CORE disk throughput is not protection or counter evidence
Native per-disk read/write rates reach existing disk chart History under the
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index a4b0da0070..1d42085402 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -1196,6 +1196,109 @@ describe('independent Proxmox backup inventory reads', () => {
apiFetchJSONMock.mockResolvedValue({ data: [], policy: protectionPolicy });
});
+ const duplicateCases = [
+ ['pve', 'backupTasks'],
+ ['pve', 'storageBackups'],
+ ['pve', 'guestSnapshots'],
+ ['pbs', 'backups'],
+ ] as const;
+ const duplicated = (source: 'pve' | 'pbs', key: string, conflicting = false) => {
+ const data: Record<string, unknown> = {
+ ...(source === 'pbs' ? pbsPayload.data : pvePayload.data),
+ };
+ const [row] = data[key] as Record<string, unknown>[];
+ data[key] = [
+ row,
+ conflicting
+ ? { ...row, instance: 'UNACCEPTED_CONNECTION', status: 'failed', size: 2 ** 40 }
+ : row,
+ ];
+ return { data };
+ };
+
+ it.each(duplicateCases)(
+ 'rejects an initial duplicate %s %s collection without hiding the independent source',
+ async (source, key) => {
+ apiFetchMock.mockImplementation((url: string) =>
+ Promise.resolve(
+ jsonResponse(
+ url.endsWith(`/${source}`)
+ ? duplicated(source, key)
+ : source === 'pve'
+ ? pbsPayload
+ : readPvePayload,
+ ),
+ ),
+ );
+ mountBackupReadState();
+ await screen.findByText(/The response format is invalid/);
+ await waitFor(() => expect(recoverableRows()).toHaveLength(1));
+ expect(screen.queryByText('No backups yet')).not.toBeInTheDocument();
+ expect(screen.getByText('Backup inventory is incomplete')).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: `Retry ${source.toUpperCase()} inventory` }),
+ ).toBeEnabled();
+ expect(document.querySelectorAll('[data-testid="proxmox-recoverable-detail"]')).toHaveLength(
+ 0,
+ );
+ },
+ );
+
+ it.each(duplicateCases)(
+ 'retains accepted details/counts after a duplicate %s %s refresh, retries only that source and rejects recurrence',
+ async (source, key) => {
+ let bad = false;
+ apiFetchMock.mockImplementation((url: string) =>
+ Promise.resolve(
+ jsonResponse(
+ bad && url.endsWith(`/${source}`)
+ ? duplicated(source, key, true)
+ : url.endsWith('/pbs')
+ ? pbsPayload
+ : pvePayload,
+ ),
+ ),
+ );
+ vi.useFakeTimers({ toFake: ['setInterval', 'clearInterval'] });
+ try {
+ mountBackupReadState();
+ await waitFor(() => expect(recoverableRows()).toHaveLength(3));
+ const firstRow = recoverableRows()[0] as HTMLElement;
+ fireEvent.click(within(firstRow).getByRole('button', { name: /expand details/i }));
+ const detail = await screen.findByTestId('proxmox-recoverable-detail');
+ const accepted = detail.textContent;
+ bad = true;
+ await vi.advanceTimersByTimeAsync(30_000);
+ await screen.findByText(/The response format is invalid/);
+ expect(recoverableRows()).toHaveLength(3);
+ expect(screen.getByTestId('proxmox-recoverable-detail')).toBe(detail);
+ expect(detail.textContent).toBe(accepted);
+ expect(document.body).not.toHaveTextContent('UNACCEPTED_CONNECTION');
+ expect(screen.getByText(/The response format is invalid/)).toHaveTextContent(
+ 'Counts are incomplete.',
+ );
+ const other = source === 'pve' ? 'pbs' : 'pve';
+ const before = sourceCalls(other).length;
+ const retry = screen.getByRole('button', {
+ name: `Retry ${source.toUpperCase()} inventory`,
+ });
+ bad = false;
+ fireEvent.click(retry);
+ await waitFor(() => expect(retry).not.toBeInTheDocument());
+ expect(sourceCalls(other)).toHaveLength(before);
+ expect(recoverableRows()).toHaveLength(3);
+ expect(screen.getByTestId('proxmox-recoverable-detail')).toHaveTextContent(accepted!);
+ bad = true;
+ await vi.advanceTimersByTimeAsync(30_000);
+ await screen.findByText(/The response format is invalid/);
+ expect(recoverableRows()).toHaveLength(3);
+ expect(document.body).not.toHaveTextContent('UNACCEPTED_CONNECTION');
+ } finally {
+ vi.useRealTimers();
+ }
+ },
+ );
+
it.each(['pve', 'pbs'] as const)(
'keeps malformed HTTP200 %s responses source-local and recovers with an isolated retry',
async (source) => {
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupInventory.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupInventory.test.ts
index fceb21e9cb..203781550c 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupInventory.test.ts
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupInventory.test.ts
@@ -14,6 +14,47 @@ const pveData = { backupTasks: [task], storageBackups: [archive], guestSnapshots
const pbsData = { backups: [pbs] };
describe('backup inventory response boundary', () => {
+ it.each(['backupTasks', 'storageBackups', 'guestSnapshots'] as const)(
+ 'rejects identical and conflicting duplicate %s IDs without choosing or dropping rows',
+ (key) => {
+ const row = pveData[key][0];
+ for (const duplicate of [row, { ...row, vmid: 113, instance: 'other-connection' }]) {
+ expect(() =>
+ parsePVEBackupInventory({ data: { ...pveData, [key]: [row, duplicate] } }),
+ ).toThrow(BackupInventoryFormatError);
+ }
+ },
+ );
+
+ it('rejects identical and conflicting duplicate PBS IDs, even with different repository hints', () => {
+ for (const duplicate of [pbs, { ...pbs, vmid: '113', instance: 'other', datastore: 'other' }]) {
+ expect(() => parsePBSBackupInventory({ data: { backups: [pbs, duplicate] } })).toThrow(
+ BackupInventoryFormatError,
+ );
+ }
+ });
+
+ it('preserves distinct opaque IDs and the independent collection namespaces', () => {
+ const data = {
+ backupTasks: [
+ { ...task, id: 'shared' },
+ { ...task, id: ' shared ' },
+ ],
+ storageBackups: [
+ { ...archive, id: 'shared' },
+ { ...archive, id: 'Shared' },
+ ],
+ guestSnapshots: [
+ { ...snapshot, id: 'shared' },
+ { ...snapshot, id: 'other' },
+ ],
+ };
+ expect(parsePVEBackupInventory({ data })).toEqual(data);
+ expect(
+ parsePBSBackupInventory({ data: { backups: [pbs, { ...pbs, id: 'other' }] } }).backups,
+ ).toEqual([pbs, { ...pbs, id: 'other' }]);
+ });
+
it('keeps observed rows, missing optional facts and future fields without coercion', () => {
const data = {
...pveData,
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupInventory.ts b/frontend-modern/src/features/proxmox/proxmoxBackupInventory.ts
index 485bae6d0e..c6afd472de 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupInventory.ts
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupInventory.ts
@@ -89,7 +89,7 @@ function inventoryData(payload: unknown): Record<string, unknown> {
return payload.data;
}
-function collection<T>(
+function collection<T extends { id: string }>(
data: Record<string, unknown>,
key: string,
shape: RowShape,
@@ -106,7 +106,14 @@ function collection<T>(
) {
throw new BackupInventoryFormatError();
}
- return value as T[];
+ const rows = value as T[];
+ // IDs own disclosure state and restore-point counts. Even identical repeats
+ // are not independent evidence; conflicting repeats cannot choose a winner.
+ // Each source collection has its own namespace, matching the model's keys.
+ if (new Set(rows.map((row) => row.id)).size !== rows.length) {
+ throw new BackupInventoryFormatError();
+ }
+ return rows;
}
export function parsePVEBackupInventory(payload: unknown): PVEBackupsPayload {