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.

Keep malformed TrueNAS protection dates unknown

pulse-triage[bot]0fd66c4ad107
diff --git a/docs/release-control/v6/internal/HIGH_RISK_RELEASE_VERIFICATION_MATRIX.md b/docs/release-control/v6/internal/HIGH_RISK_RELEASE_VERIFICATION_MATRIX.md
index 618cbab8e4..d8335c6636 100644
--- a/docs/release-control/v6/internal/HIGH_RISK_RELEASE_VERIFICATION_MATRIX.md
+++ b/docs/release-control/v6/internal/HIGH_RISK_RELEASE_VERIFICATION_MATRIX.md
@@ -8,6 +8,19 @@ A gate is only `passed` when its automated proof still passes and the manual
scenario has been exercised in a staging-like environment with the expected
result.
+## TrueNAS protection timestamp admission
+
+Automated: `TrueNASProtectionTable.test.tsx`, existing completion and
+refresh tests, `truenasPageModel.test.ts` and the shared backup timestamp suite.
+Send synthetic recovery-points JSON through the real query and normalizer into
+Protection on desktop and 320px touch. Impossible dates and timezone-free values
+say Unknown instead of normalising to a date; open details to inspect the original
+Started/Completed strings. Sort in both directions with unknowns last, preserving
+failure priority in default order, absent/running completions and valid explicit
+zones/fractions. Refresh the same open record from invalid to valid evidence and
+back; inspect actual pixels and focus as well as DOM values. No native/production
+operation or original incident replay is part of this consumer proof.
+
## Workloads guest interface source selection — issue #2757
Automated: `useWorkloads.test.ts` (both REST and owning-snapshot VM/LXC
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index fb4da70898..63b27aec8a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -20,6 +20,18 @@
## Purpose
+### TrueNAS protection consumers do not repair malformed instants
+
+The Protection row, completion sorts and inline Started/Completed fields use the
+shared explicit-zone, calendar-valid backup instant rule. Invalid reported values
+remain Unknown, with the literal evidence retained in details rather than a
+browser-repaired date. Unknowns have no chronological rank; outcome priority,
+absent/active completion handling, identity and policy remain unchanged.
+`TrueNASProtectionTable.test.tsx` drives the query/transport normalizer into these
+consumers with malformed and valid-offset controls; desktop/narrow browser pixels
+and interactions remain required. This is not native protection or guest recovery.
+
+
### Missing Workloads completion times do not establish absence
The workload badge, compact shield, hover/dialog and full drawer treat absent
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 56791f981f..95849e6721 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -556,6 +556,25 @@ desktop and narrow browser proof establishes actual fit and interaction; a DOM
class assertion alone does not establish readability. No date, outcome, query,
API, identity, policy or recovery operation changes.
+### TrueNAS protection dates require observed instants
+
+The Protection table and its inline Started/Completed details use the shared
+backup timestamp admission rule: a calendar-valid RFC3339 instant with an
+explicit zone. Impossible dates, date-only strings, local times and invalid
+clock fields are not repaired by the browser. A malformed reported completion
+says Unknown in the row; details retain the original string beside Unknown date.
+Absent finishes and active runs still show no completion. Valid explicit offsets
+and fractional seconds retain their instant and normal localised presentation.
+
+Malformed values sort after dated values in either explicit completion direction.
+The default attention-first order also gives unknown dates no chronological rank,
+without substituting a start for a non-empty malformed finish. The normal-suite
+`TrueNASProtectionTable.test.tsx` exercises the actual query/transport
+normalizer, table, details and sorting, with valid leap-day/offset controls.
+Stored data, outcomes, policy, verification and native recovery are unchanged.
+Source-bound desktop and narrow browser interactions/pixels remain required;
+these synthetic cases establish consumer admission, not original incident recovery.
+
### TrueNAS start and active-run dates are not completion evidence
The Protection table's Completed column, its explicit completion sort and its
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 9ed78f5406..0fbb15e90b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -23,6 +23,18 @@ and sort the complete canonical change table while startup and ingestion wait.
## Purpose
+### TrueNAS protection consumers do not repair malformed instants
+
+The Protection row, completion sorts and inline Started/Completed fields use the
+shared explicit-zone, calendar-valid backup instant rule. Invalid reported values
+remain Unknown, with the literal evidence retained in details rather than a
+browser-repaired date. Unknowns have no chronological rank; outcome priority,
+absent/active completion handling, identity and policy remain unchanged.
+`TrueNASProtectionTable.test.tsx` drives the query/transport normalizer into these
+consumers with malformed and valid-offset controls; desktop/narrow browser pixels
+and interactions remain required. This is not native protection or guest recovery.
+
+
### Native rate instants survive canonical cloning
`MetricValue.ObservedAt` is an optional internal-only sample instant copied with
diff --git a/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx b/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
index 5f6c9e0f9c..1e5a7b8f7e 100644
--- a/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
+++ b/frontend-modern/src/features/truenas/TrueNASProtectionTable.tsx
@@ -10,6 +10,7 @@ import {
normalizeRecoveryOutcome,
} from '@/utils/recoveryOutcomePresentation';
import { asTrimmedString } from '@/utils/stringUtils';
+import { parseBackupTimestampMs } from '@/utils/backupTimestamp';
import type { StatusIndicatorVariant } from '@/utils/status';
import {
PlatformWindowedRows,
@@ -24,7 +25,6 @@ import {
createPlatformTableSortState,
formatPlatformTableBytesValue,
getPlatformTableCellClassForKind,
- getPlatformTableDateTimeSortValue,
withPlatformStatusCounts,
type PlatformTableFilterOption,
type PlatformTableSortValue,
@@ -210,7 +210,7 @@ const getTrueNASProtectionSortValue = (
return target === '-' ? null : target;
}
case 'completed':
- return getPlatformTableDateTimeSortValue(completionTimestamp(point));
+ return parseBackupTimestampMs(completionTimestamp(point)) ?? null;
case 'size':
return typeof point.sizeBytes === 'number' && Number.isFinite(point.sizeBytes)
? point.sizeBytes
@@ -234,9 +234,11 @@ const detailBool = (value?: boolean | null): string | null => {
const detailDateTime = (value?: string | null): string | null => {
const raw = asTrimmedString(value);
if (!raw) return null;
- const parsed = new Date(raw);
- if (Number.isNaN(parsed.getTime())) return raw;
- return parsed.toLocaleString(undefined, {
+ const timestamp = parseBackupTimestampMs(raw);
+ // Keep malformed evidence inspectable without letting Date repair its
+ // calendar or invent a browser-local zone. It is not an observed instant.
+ if (timestamp === undefined) return `Unknown date (${raw})`;
+ return new Date(timestamp).toLocaleString(undefined, {
month: 'short',
day: 'numeric',
year: 'numeric',
@@ -596,8 +598,8 @@ export const TrueNASProtectionTable: Component<{
class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}
>
<PlatformTableDateTimeValue
- value={completionTimestamp(point)}
- emptyText="-"
+ value={parseBackupTimestampMs(completionTimestamp(point))}
+ emptyText={completionTimestamp(point) ? 'Unknown' : '-'}
/>
</TableCell>
<TableCell
diff --git a/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.completion.test.tsx b/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.completion.test.tsx
index a0d51c7f10..1b1115095a 100644
--- a/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.completion.test.tsx
+++ b/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.completion.test.tsx
@@ -139,9 +139,10 @@ describe('TrueNAS protection completion evidence', () => {
mountProtection();
await vi.waitFor(() => expect(row('completed')).not.toBeNull());
- for (const id of ['running', 'started-only', 'failed-started-only', 'unknown', 'invalid']) {
+ for (const id of ['running', 'started-only', 'failed-started-only', 'unknown']) {
expect(completion(id)).toHaveTextContent(/^\s*-\s*$/);
}
+ expect(completion('invalid')).toHaveTextContent('Unknown');
for (const id of ['completed', 'failed-completed']) {
expect(completion(id)).not.toHaveTextContent(/^\s*-\s*$/);
}
diff --git a/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsx b/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsx
index e85eaf2320..2912ad9cde 100644
--- a/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsx
+++ b/frontend-modern/src/features/truenas/__tests__/TrueNASProtectionTable.test.tsx
@@ -1,10 +1,13 @@
import { cleanup, fireEvent, render, screen, within } from '@solidjs/testing-library';
import { Route, Router } from '@solidjs/router';
import type { JSX } from 'solid-js';
-import { afterEach, describe, expect, it } from 'vitest';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import { TrueNASProtectionTable } from '@/features/truenas/TrueNASProtectionTable';
-import type { RecoveryPoint } from '@/types/recovery';
+import type { RecoveryPoint, RecoveryPointTransport } from '@/types/recovery';
+import { sortTrueNASProtectionPoints } from '@/features/truenas/truenasPageModel';
+import { resetCreateNonSuspendingQueryCacheForTest } from '@/hooks/createNonSuspendingQuery';
+import { useRecoveryPoints } from '@/hooks/useRecoveryPoints';
// Record drawers link to the object they are about, which needs a router.
const renderInRouter = (component: () => JSX.Element) =>
@@ -238,3 +241,147 @@ describe('TrueNASProtectionTable', () => {
);
});
});
+
+const apiFetchJSON = vi.hoisted(() => vi.fn());
+vi.mock('@/utils/apiClient', () => ({ apiFetchJSON }));
+
+const point = (
+ id: string,
+ overrides: Partial<RecoveryPointTransport> = {},
+): RecoveryPointTransport => ({
+ id,
+ platform: 'truenas',
+ kind: 'backup',
+ mode: 'remote',
+ outcome: 'success',
+ startedAt: '2026-09-29T01:00:00Z',
+ completedAt: '2026-09-30T01:15:00Z',
+ display: { subjectLabel: `tank/${id}`, subjectType: 'dataset' },
+ ...overrides,
+});
+
+function mount(points: RecoveryPointTransport[]) {
+ apiFetchJSON.mockResolvedValue({ data: points });
+ render(() => (
+ <Router>
+ <Route
+ path="/*"
+ component={() => {
+ const recovery = useRecoveryPoints(() => ({ platform: 'truenas', page: 1, limit: 200 }));
+ return (
+ <TrueNASProtectionTable
+ points={recovery.points()}
+ emptyIcon={<span />}
+ emptyTitle="No protection"
+ emptyDescription="No events in this response."
+ />
+ );
+ }}
+ />
+ </Router>
+ ));
+}
+
+const row = (id: string) =>
+ document.querySelector<HTMLElement>(`[data-truenas-protection-row="${id}"]`)!;
+const completion = (id: string) => row(id).querySelectorAll('td')[3]!;
+const rowIDs = () =>
+ [...document.querySelectorAll('[data-truenas-protection-row]')].map((item) =>
+ item.getAttribute('data-truenas-protection-row'),
+ );
+
+afterEach(() => {
+ cleanup();
+ apiFetchJSON.mockReset();
+ resetCreateNonSuspendingQueryCacheForTest();
+ localStorage.clear();
+});
+
+describe('TrueNAS protection timestamp admission', () => {
+ it.each([
+ '2026-09-31T01:15:00Z',
+ '2026-02-29T01:15:00Z',
+ '2026-09-30T01:15:00',
+ '2026-09-30',
+ '2026-09-30T24:00:00Z',
+ 'not-a-date',
+ ])(
+ 'keeps a malformed reported date unknown in the row and both detail fields: %s',
+ async (raw) => {
+ mount([point('malformed', { startedAt: raw, completedAt: raw, outcome: 'failed' })]);
+ await vi.waitFor(() => expect(row('malformed')).not.toBeNull());
+ expect(completion('malformed')).toHaveTextContent(/^Unknown$/);
+ expect(row('malformed')).toHaveAttribute('data-truenas-protection-outcome', 'failed');
+ await fireEvent.click(within(row('malformed')).getByRole('button', { name: /details/i }));
+ const detail = within(screen.getByTestId('truenas-protection-detail'));
+ for (const label of ['Started', 'Completed']) {
+ expect(detail.getByText(label, { exact: true }).closest('tr')).toHaveTextContent(
+ `Unknown date (${raw})`,
+ );
+ }
+ expect(apiFetchJSON).toHaveBeenCalledWith(
+ '/api/recovery/points?page=1&limit=200&platform=truenas',
+ );
+ },
+ );
+
+ it.each([
+ '2024-02-29T01:15:00.123456789+01:30',
+ '2026-09-30T01:15:00Z',
+ '2026-09-29T23:15:00-02:00',
+ ])('preserves valid explicit instants through the real transport normalizer: %s', async (raw) => {
+ mount([point('valid', { startedAt: raw, completedAt: raw })]);
+ await vi.waitFor(() => expect(row('valid')).not.toBeNull());
+ expect(completion('valid')).not.toHaveTextContent(/Unknown|^\s*-\s*$/);
+ await fireEvent.click(within(row('valid')).getByRole('button', { name: /details/i }));
+ const detail = within(screen.getByTestId('truenas-protection-detail'));
+ const expected = new Date(raw).toLocaleString(undefined, {
+ month: 'short',
+ day: 'numeric',
+ year: 'numeric',
+ hour: '2-digit',
+ minute: '2-digit',
+ });
+ for (const label of ['Started', 'Completed']) {
+ expect(detail.getByText(label, { exact: true }).closest('tr')).toHaveTextContent(expected);
+ }
+ });
+
+ it('keeps malformed completions last in either completion sort direction without borrowing starts', async () => {
+ mount([
+ point('malformed', {
+ completedAt: '2026-09-31T01:15:00Z',
+ startedAt: '2026-10-02T00:00:00Z',
+ }),
+ point('missing', { completedAt: undefined }),
+ point('older', { completedAt: '2026-09-29T01:15:00Z' }),
+ point('newer'),
+ ]);
+ await vi.waitFor(() => expect(row('malformed')).not.toBeNull());
+ const sort = within(screen.getByRole('columnheader', { name: /Completed/ })).getByRole(
+ 'button',
+ );
+ await fireEvent.click(sort);
+ expect(rowIDs().slice(0, 2)).toEqual(['newer', 'older']);
+ expect(rowIDs().slice(2).sort()).toEqual(['malformed', 'missing']);
+ await fireEvent.click(sort);
+ expect(rowIDs().slice(0, 2)).toEqual(['older', 'newer']);
+ expect(rowIDs().slice(2).sort()).toEqual(['malformed', 'missing']);
+ });
+
+ it('does not give malformed dates a default chronological rank, and preserves attention priority', () => {
+ const valid = point('valid', { completedAt: '1960-01-01T00:00:00Z' });
+ const malformed = point('malformed', { completedAt: '2026-09-31T01:15:00Z' });
+ const absent = point('absent', { completedAt: undefined, startedAt: undefined });
+ expect(sortTrueNASProtectionPoints([absent, malformed, valid]).map(({ id }) => id)).toEqual([
+ 'valid',
+ 'absent',
+ 'malformed',
+ ]);
+ const failed = point('failed', { outcome: 'failed', completedAt: '2026-09-31T01:15:00Z' });
+ expect(sortTrueNASProtectionPoints([valid, failed]).map(({ id }) => id)).toEqual([
+ 'failed',
+ 'valid',
+ ]);
+ });
+});
diff --git a/frontend-modern/src/features/truenas/truenasPageModel.ts b/frontend-modern/src/features/truenas/truenasPageModel.ts
index c07ce55ebb..d7571a1330 100644
--- a/frontend-modern/src/features/truenas/truenasPageModel.ts
+++ b/frontend-modern/src/features/truenas/truenasPageModel.ts
@@ -1,5 +1,6 @@
import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import { asTrimmedString } from '@/utils/stringUtils';
+import { parseBackupTimestampMs } from '@/utils/backupTimestamp';
import { hasImpairedResourceSource } from '@/utils/resourceSourceHealth';
import { getTrueNASDatasetStateSummary } from '@/utils/truenasDatasetState';
import type { MetricDisplayThresholds } from '@/utils/metricThresholds';
@@ -633,12 +634,10 @@ const normalizeProtectionOutcome = (value: unknown): TrueNASProtectionStatusBuck
return 'unknown';
};
-const getRecoveryPointTimestampMs = (point: RecoveryPoint): number => {
- const parsed = Date.parse(
+const getRecoveryPointTimestampMs = (point: RecoveryPoint): number | undefined =>
+ parseBackupTimestampMs(
asTrimmedString(point.completedAt) || asTrimmedString(point.startedAt) || '',
);
- return Number.isFinite(parsed) ? parsed : 0;
-};
const titleize = (value: string): string =>
value
@@ -984,7 +983,13 @@ export function sortTrueNASProtectionPoints(points: readonly RecoveryPoint[]): R
const attentionDelta =
trueNASProtectionAttentionRank(left) - trueNASProtectionAttentionRank(right);
if (attentionDelta !== 0) return attentionDelta;
- const timeDelta = getRecoveryPointTimestampMs(right) - getRecoveryPointTimestampMs(left);
+ const leftTime = getRecoveryPointTimestampMs(left);
+ const rightTime = getRecoveryPointTimestampMs(right);
+ // Unknown dates have no chronological rank, including next to pre-epoch
+ // instants. A malformed completion cannot borrow a valid start instead.
+ if (leftTime === undefined && rightTime !== undefined) return 1;
+ if (rightTime === undefined && leftTime !== undefined) return -1;
+ const timeDelta = (rightTime ?? 0) - (leftTime ?? 0);
if (timeDelta !== 0) return timeDelta;
const leftLabel =
asTrimmedString(left.display?.itemLabel) || asTrimmedString(left.itemRef?.name) || left.id;