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
Stabilize reporting validation codes
rcourtman4af58959018b
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.mdindex f9613e9dbc..71face61bb 100644--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md@@ -294,6 +294,9 @@ Those same lifecycle-triggered reporting calls must also stay inside theAPI-owned `metricType`/`title` limits and the strict multi-report JSON bodyrules instead of assuming the backend will coerce malformed payloads into abest-effort report.+When those lifecycle-adjacent calls fail validation, adjacent automation should+rely on the API-owned error codes rather than message-text heuristics, because+the backend contract owns the reporting validation classification.The direct Proxmox fallback workspace now also lives explicitly inside thislifecycle boundary: `InfrastructureWorkspace.tsx`,`infrastructureWorkspaceModel.ts`,diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.mdindex ac24f2ddfb..606b297166 100644--- a/docs/release-control/v6/internal/subsystems/api-contracts.md+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md@@ -300,6 +300,10 @@ stay within the governed length cap, and the multi-report JSON body must remainstrictly parsed with the canonical size ceiling, unknown-field rejection, andno trailing payload tolerance instead of accepting malformed operator input anddrifting onward.+Those validation failures also keep stable API error codes owned by the backend+contract itself; handlers must not infer `invalid_metric_type`,+`invalid_title`, or similar response codes by parsing their own human-readable+error text.The catalog route itself is intentionally metadata-readable without the`advanced_reporting` feature gate so locked admin surfaces can present the samecanonical reporting definition before upsell, while report generation anddiff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.mdindex 35972c6b16..f5a1a4105f 100644--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md@@ -165,6 +165,11 @@ compatibility input that rewrites back to canonical `platform` route state.Shared recovery link builders should therefore accept canonical `platform`inputs only; legacy `provider` belongs at parse-time compatibility boundaries,not in new caller-facing recovery route helpers.+Cross-surface recovery drill-in links must also declare the correct primary+workspace instead of relying on the inventory-first page default. When a+platform service surface such as PBS links into recovery activity, that shared+entry point should land on canonical `view=events` and describe the destination+as recovery events rather than reverting to PBS-backup wording.That same recovery contract should keep response payloads canonical as well:recovery points and protected rollups should expose `platform` and`platforms` as the primary transport fields, while any legacy@@ -311,6 +316,9 @@ storage and recovery automation must preserve: bad or oversized multi-reportpayloads fail as `invalid_body` or `body_too_large`, and overlong reportwindows or invalid optional fields fail through the API-owned reportingvalidation contract instead of being clipped or normalized locally.+That same API-owned contract also classifies those validation failures with+stable error codes, so storage and recovery flows must not derive behavior by+inspecting human-readable error text from adjacent reporting calls.That adjacent export contract now also includes canonical Proxmox poolmembership for each VM row. Storage and recovery flows may use those current-state facts when they need fleet context, but they must consume the API-owneddiff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex fda3bccccc..0acf027b37 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -627,6 +627,40 @@ func TestContract_PerformanceReportTransportRejectsOversizedMultiBody(t *testing}}+func TestContract_PerformanceReportTransportRejectsInvalidOptionalFieldWithStableCode(t *testing.T) {+ engine := &stubReportingEngine{data: []byte("report"), contentType: "application/pdf"}+ original := reporting.GetEngine()+ reporting.SetEngine(engine)+ t.Cleanup(func() { reporting.SetEngine(original) })++ handler := NewReportingHandlers(nil, nil)+ req := httptest.NewRequest(+ http.MethodGet,+ "/api/reporting?resourceType=node&resourceId=node-1&metricType="+url.QueryEscape("cpu usage"),+ nil,+ )+ rec := httptest.NewRecorder()++ handler.HandleGenerateReport(rec, req)++ if rec.Code != http.StatusBadRequest {+ t.Fatalf("expected 400, got %d body=%s", rec.Code, rec.Body.String())+ }+ var payload struct {+ Code string `json:"code"`+ Error string `json:"error"`+ }+ if err := json.NewDecoder(rec.Body).Decode(&payload); err != nil {+ t.Fatalf("decode invalid optional-field response: %v", err)+ }+ if payload.Code != "invalid_metric_type" {+ t.Fatalf("expected invalid_metric_type code, got %q", payload.Code)+ }+ if payload.Error != "metricType must match [a-zA-Z0-9._:-]+ and be <= 64 chars" {+ t.Fatalf("expected canonical invalid_metric_type message, got %q", payload.Error)+ }+}+func TestContract_ReportingInvalidFormatErrorsUseCatalogDefinitions(t *testing.T) {engine := &stubReportingEngine{data: []byte("report"), contentType: "application/pdf"}original := reporting.GetEngine()diff --git a/internal/api/metrics_reporting_handlers.go b/internal/api/metrics_reporting_handlers.goindex b33d3eec87..7cd3ea42df 100644--- a/internal/api/metrics_reporting_handlers.go+++ b/internal/api/metrics_reporting_handlers.go@@ -30,6 +30,18 @@ const (reportingMultiReportBodyMax = 1 << 20)+type reportingValidationError struct {+ code string+ message string+}++func (e *reportingValidationError) Error() string {+ if e == nil {+ return ""+ }+ return e.message+}+func normalizeReportResourceType(raw string) (string, error) {trimmed := strings.TrimSpace(raw)if trimmed == "" {@@ -79,13 +91,19 @@ func normalizePerformanceReportOptionalFields(normalizedMetricType = ""} else if normalizedMetricType != "" {if len(normalizedMetricType) > reportingMaxMetricTypeLength || !validReportingMetricType.MatchString(normalizedMetricType) {- return "", "", fmt.Errorf("metricType must match [a-zA-Z0-9._:-]+ and be <= %d chars", reportingMaxMetricTypeLength)+ return "", "", &reportingValidationError{+ code: "invalid_metric_type",+ message: fmt.Sprintf("metricType must match [a-zA-Z0-9._:-]+ and be <= %d chars", reportingMaxMetricTypeLength),+ }}}if !definition.SupportsCustomTitle {normalizedTitle = ""} else if len(normalizedTitle) > reportingMaxTitleLength {- return "", "", fmt.Errorf("title must be <= %d chars", reportingMaxTitleLength)+ return "", "", &reportingValidationError{+ code: "invalid_title",+ message: fmt.Sprintf("title must be <= %d chars", reportingMaxTitleLength),+ }}return normalizedMetricType, normalizedTitle, nil@@ -404,8 +422,9 @@ func (h *ReportingHandlers) HandleGenerateReport(w http.ResponseWriter, r *http.)if err != nil {code := "invalid_metric_type"- if strings.HasPrefix(err.Error(), "title ") {- code = "invalid_title"+ var validationErr *reportingValidationError+ if errors.As(err, &validationErr) && validationErr.code != "" {+ code = validationErr.code}writeErrorResponse(w, http.StatusBadRequest, code, err.Error(), nil)return@@ -752,8 +771,9 @@ func (h *ReportingHandlers) HandleGenerateMultiReport(w http.ResponseWriter, r *metricType, title, err := normalizePerformanceReportOptionalFields(definition, body.MetricType, body.Title)if err != nil {code := "invalid_metric_type"- if strings.HasPrefix(err.Error(), "title ") {- code = "invalid_title"+ var validationErr *reportingValidationError+ if errors.As(err, &validationErr) && validationErr.code != "" {+ code = validationErr.code}writeErrorResponse(w, http.StatusBadRequest, code, err.Error(), nil)return