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.

Fallback reporting catalog for legacy backends

rcourtman168c659d63c3
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index c4c5bcd420..9b77a26fa8 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -308,6 +308,12 @@ The catalog route itself is intentionally metadata-readable without the
`advanced_reporting` feature gate so locked admin surfaces can present the same
canonical reporting definition before upsell, while report generation and
inventory export remain feature-gated execution routes.
+That metadata route is still a version boundary as well. Current Pulse servers
+must expose `/api/admin/reports/catalog`, but frontend consumers may treat a
+`404` from that route as an old-backend compatibility signal and fall back to
+the legacy report-generation transport only; they must not synthesize or guess
+the newer catalog-owned inventory export contract when the backend does not
+provide it.
The `/api/resources` serializer now also refreshes canonical identity and
policy metadata through the shared unified-resource helper before it writes
the payload, so backend and frontend contract tests stay aligned on one
@@ -1465,13 +1471,6 @@ must also project the effective default-org hosted lease when the tenant-local
billing file has not been materialized yet, so admin billing-state payloads
stay coherent with the tenant's active entitlement payload instead of briefly
regressing to local trial/default state.
-That same hosted handoff boundary also owns tenant-context recovery inside the
-tenant runtime itself. When older hosted containers are missing explicit
-`PULSE_TENANT_ID`, `internal/api/cloud_handoff_handlers.go` must recover the
-JWT audience/tenant context from hosted-only runtime inputs like
-`PULSE_PUBLIC_URL` or the hosted tenant request host before it mints the
-browser session, rather than failing a valid control-plane handoff with a
-generic `500 internal error`.
Canonical missing-resource lookups in governed frontend API clients must now
also route `404 => null` response handling through shared response helpers in
`frontend-modern/src/api/responseUtils.ts` rather than open-coding local
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 172b2b39af..3cb9d48b9d 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -227,6 +227,13 @@ loaded.
The same metadata route is readable without the reporting feature gate, so the
settings shell must not delay the catalog fetch on `licenseLoaded()` before it
can render its canonical loading, locked, or entitled states.
+That same shell must also stay usable against older Pulse backends that do not
+yet expose `/api/admin/reports/catalog`. When that specific metadata route
+returns `404`, `useReportingPanelState.ts` may fall back to the governed legacy
+performance-report transport (`/api/reporting` and `/api/reporting/generate-multi`)
+so the reporting panel does not go dead on mixed-version installs, but that
+compatibility path is intentionally report-only and must not invent the newer
+catalog-owned VM inventory export surface.
That same catalog load must also remain retryable after transient failure.
`useReportingPanelState.ts` may memoize or dedupe in-flight work, but it must
not permanently latch a failed first fetch and force operators to reload the
diff --git a/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.ts b/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.ts
index 71cfbf381b..6c932ddf67 100644
--- a/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/reportingCatalogModel.test.ts
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
buildReportingCatalogRequest,
+ buildLegacyReportingCatalogFallback,
parseReportingCatalog,
} from '../reportingCatalogModel';
@@ -69,6 +70,14 @@ describe('reporting catalog model', () => {
});
});
+ it('builds the legacy reporting compatibility fallback', () => {
+ const catalog = buildLegacyReportingCatalogFallback();
+
+ expect(catalog.performanceReport.singleResourceEndpoint).toBe('/api/reporting');
+ expect(catalog.performanceReport.multiResourceEndpoint).toBe('/api/reporting/generate-multi');
+ expect(catalog.vmInventoryExport).toBeNull();
+ });
+
it('parses the canonical reporting catalog payload', () => {
const catalog = parseReportingCatalog(baseCatalogPayload);
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index 35292a463d..7c7f323422 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -1097,6 +1097,7 @@ describe('Settings architecture guardrails', () => {
expect(reportingPanelStateSource).not.toContain('startProTrial()');
expect(reportingPanelStateSource).toContain('buildReportingRequest');
expect(reportingPanelStateSource).toContain('buildReportingCatalogRequest');
+ expect(reportingPanelStateSource).toContain('buildLegacyReportingCatalogFallback');
expect(reportingPanelStateSource).toContain('parseReportingCatalog');
expect(reportingPanelStateSource).toContain('reportingFeatureId');
expect(reportingPanelStateSource).toContain('loadReportingCatalog = async');
@@ -1110,6 +1111,7 @@ describe('Settings architecture guardrails', () => {
expect(reportingPanelStateSource).not.toContain("'advanced_reporting'");
expect(reportingPanelStateSource).not.toContain('getTrialAlreadyUsedMessage()');
expect(reportingCatalogModelSource).toContain('export function buildReportingCatalogRequest');
+ expect(reportingCatalogModelSource).toContain('export function buildLegacyReportingCatalogFallback');
expect(reportingCatalogModelSource).toContain('export function parseReportingCatalog');
expect(reportingCatalogModelSource).toContain('interface ReportingLockedStateDefinition');
expect(reportingCatalogModelSource).toContain('interface ReportingGuidanceDefinition');
diff --git a/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts b/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
index b0ce21bb7c..337d609b08 100644
--- a/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/useReportingPanelState.test.ts
@@ -327,4 +327,51 @@ describe('useReportingPanelState', () => {
dispose();
});
+
+ it('falls back to the legacy reporting transport when the catalog route is missing', async () => {
+ vi.resetModules();
+
+ apiFetchMock = vi.fn().mockResolvedValueOnce(new Response('404 page not found', { status: 404 }));
+
+ vi.doMock('@/utils/apiClient', async () => {
+ const actual = await vi.importActual<typeof import('@/utils/apiClient')>('@/utils/apiClient');
+ return {
+ ...actual,
+ apiFetch: apiFetchMock,
+ };
+ });
+
+ vi.doMock('@/utils/toast', () => ({
+ showSuccess: vi.fn(),
+ showWarning: vi.fn(),
+ }));
+
+ vi.doMock('@/utils/trialStartAction', () => ({
+ runStartProTrialAction: vi.fn(),
+ }));
+
+ vi.doMock('@/utils/upgradeMetrics', () => ({
+ trackPaywallViewed: vi.fn(),
+ }));
+
+ vi.doMock('@/stores/license', () => ({
+ entitlements: vi.fn(() => ({ trial_eligible: true })),
+ getUpgradeActionUrlOrFallback: vi.fn(() => '/pricing'),
+ hasFeature: vi.fn((feature: string) => feature === 'advanced_reporting' && hasReportingFeature),
+ licenseLoaded: vi.fn(() => true),
+ loadLicenseStatus: loadLicenseStatusMock,
+ }));
+
+ ({ useReportingPanelState } = await import('../useReportingPanelState'));
+ const { hookState, dispose } = mountHook();
+
+ await flushAsync();
+ await flushAsync();
+
+ expect(hookState.reportingCatalogError()).toBe('');
+ expect(hookState.reportingCatalog()?.performanceReport.singleResourceEndpoint).toBe('/api/reporting');
+ expect(hookState.reportingCatalog()?.vmInventoryExport).toBeNull();
+
+ dispose();
+ });
});
diff --git a/frontend-modern/src/components/Settings/reportingCatalogModel.ts b/frontend-modern/src/components/Settings/reportingCatalogModel.ts
index 8998935ed9..554afc9777 100644
--- a/frontend-modern/src/components/Settings/reportingCatalogModel.ts
+++ b/frontend-modern/src/components/Settings/reportingCatalogModel.ts
@@ -55,7 +55,7 @@ export interface ReportingCatalog {
lockedState: ReportingLockedStateDefinition;
guidance: ReportingGuidanceDefinition;
performanceReport: ReportingPerformanceReportDefinition;
- vmInventoryExport: ReportingInventoryExportDefinition;
+ vmInventoryExport: ReportingInventoryExportDefinition | null;
}
export function buildReportingCatalogRequest(): { url: string } {
@@ -64,6 +64,63 @@ export function buildReportingCatalogRequest(): { url: string } {
};
}
+export function buildLegacyReportingCatalogFallback(): ReportingCatalog {
+ return {
+ id: 'advanced_reporting',
+ title: 'Detailed Reporting',
+ description: 'Generate performance reports across infrastructure and workloads.',
+ lockedState: {
+ title: 'Advanced Reporting (Pro)',
+ description: 'Generate PDF and CSV performance reports across infrastructure and workload resources.',
+ },
+ guidance: {
+ title: 'Advanced Insights',
+ description: 'Older Pulse servers expose the legacy reporting transport directly. Performance reports remain available here, but newer catalog-driven reporting surfaces require a newer backend.',
+ },
+ performanceReport: {
+ id: 'performance_reports',
+ title: 'Performance Reports',
+ description: 'Generate PDF summaries or CSV metric exports from historical monitoring data for one or more selected resources.',
+ singleResourceEndpoint: '/api/reporting',
+ multiResourceEndpoint: '/api/reporting/generate-multi',
+ singleFilenamePrefix: 'report',
+ singleFilenameSubject: 'resource_id',
+ multiFilenamePrefix: 'fleet-report',
+ filenameDateStyle: 'utc_yyyymmdd',
+ formats: [
+ { value: 'pdf', label: 'PDF Report' },
+ { value: 'csv', label: 'CSV Data' },
+ ],
+ defaultFormat: 'pdf',
+ ranges: [
+ {
+ key: '24h',
+ label: 'Last 24 Hours',
+ description: 'Current-day operational summary for short-term regressions.',
+ windowHours: 24,
+ },
+ {
+ key: '7d',
+ label: 'Last 7 Days',
+ description: 'Weekly trend window for recent performance changes.',
+ windowHours: 168,
+ },
+ {
+ key: '30d',
+ label: 'Last 30 Days',
+ description: 'Monthly review window for sustained capacity or reliability shifts.',
+ windowHours: 720,
+ },
+ ],
+ defaultRange: '24h',
+ multiResourceMax: 50,
+ supportsMetricFilter: true,
+ supportsCustomTitle: true,
+ },
+ vmInventoryExport: null,
+ };
+}
+
function parseReportingFormatDefinition(input: unknown): ReportingFormatDefinition {
if (!input || typeof input !== 'object') {
throw new Error('Invalid reporting catalog payload');
diff --git a/frontend-modern/src/components/Settings/useReportingPanelState.ts b/frontend-modern/src/components/Settings/useReportingPanelState.ts
index 06d3e5cc9f..1ab7a74a87 100644
--- a/frontend-modern/src/components/Settings/useReportingPanelState.ts
+++ b/frontend-modern/src/components/Settings/useReportingPanelState.ts
@@ -29,6 +29,7 @@ import {
buildVMInventoryExportRequest,
} from '@/components/Settings/reportingInventoryExportModel';
import {
+ buildLegacyReportingCatalogFallback,
buildReportingCatalogRequest,
parseReportingCatalog,
type ReportingCatalog,
@@ -86,7 +87,12 @@ export const useReportingPanelState = () => {
const request = buildReportingCatalogRequest();
const response = await apiFetch(request.url);
if (!response.ok) {
- throw await apiErrorFromResponse(response, getReportingCatalogErrorMessage());
+ const error = await apiErrorFromResponse(response, getReportingCatalogErrorMessage());
+ if ((error as { status?: number }).status === 404) {
+ setReportingCatalog(buildLegacyReportingCatalogFallback());
+ return;
+ }
+ throw error;
}
setReportingCatalog(parseReportingCatalog(await response.json()));