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
Diagnostics: handle blank-name instances; add report-token router test
rcourtmanefb6976069f9
diff --git a/internal/api/diagnostics.go b/internal/api/diagnostics.goindex 58f8e54bed..055efe797a 100644--- a/internal/api/diagnostics.go+++ b/internal/api/diagnostics.go@@ -860,7 +860,14 @@ func (r *Router) computeDiagnostics(ctx context.Context) DiagnosticsInfo {Host: node.Host,Type: "pve",}- monitorConnected, hasMonitorStatus := diagnosticsMonitorConnectionStatus(r.monitor, "pve-"+node.Name)+ // GetConnectionStatuses keys by name, falling back to host when the+ // configured name is empty; mirror that so the merge is not a silent+ // no-op for unnamed instances.+ pveKeyName := node.Name+ if strings.TrimSpace(pveKeyName) == "" {+ pveKeyName = node.Host+ }+ monitorConnected, hasMonitorStatus := diagnosticsMonitorConnectionStatus(r.monitor, "pve-"+pveKeyName)// Determine auth method (sanitized - don't expose actual values)if node.TokenName != "" && node.TokenValue != "" {@@ -933,7 +940,11 @@ func (r *Router) computeDiagnostics(ctx context.Context) DiagnosticsInfo {Name: pbsNode.Name,Host: pbsNode.Host,}- monitorConnected, hasMonitorStatus := diagnosticsMonitorConnectionStatus(r.monitor, "pbs-"+pbsNode.Name)+ pbsKeyName := pbsNode.Name+ if strings.TrimSpace(pbsKeyName) == "" {+ pbsKeyName = pbsNode.Host+ }+ monitorConnected, hasMonitorStatus := diagnosticsMonitorConnectionStatus(r.monitor, "pbs-"+pbsKeyName)testCfg := pbs.ClientConfig{Host: pbsNode.Host,diff --git a/internal/api/unified_agent_config_binding_router_test.go b/internal/api/unified_agent_config_binding_router_test.goindex ccb77f1a28..df2e774d6a 100644--- a/internal/api/unified_agent_config_binding_router_test.go+++ b/internal/api/unified_agent_config_binding_router_test.go@@ -46,3 +46,30 @@ func TestUnifiedAgentConfigUsesTokenBindingInRouter(t *testing.T) {}}}++// Regression for #1254: canReadConfig accepts agent:report, but a report-only+// token that is NOT bound to any host must still be rejected (404 from token+// binding, not 200) — verified at the full router level.+func TestUnifiedAgentConfigReportScopeUnboundReturnsNotFound(t *testing.T) {+ rawToken := "host-report-unbound-token-123.12345678"+ record := newTokenRecord(t, rawToken, []string{config.ScopeAgentReport}, nil)+ record.ID = "token-unbound"++ cfg := newTestConfigWithTokens(t, record)++ state := models.NewState()+ state.UpsertHost(models.Host{ID: "host-1", TokenID: "token-other"})+ monitor := &monitoring.Monitor{}+ setUnexportedField(t, monitor, "state", state)++ router := NewRouter(cfg, monitor, nil, nil, nil, "1.0.0")++ req := httptest.NewRequest(http.MethodGet, "/api/agents/agent/host-1/config", nil)+ req.Header.Set("X-API-Token", rawToken)+ rec := httptest.NewRecorder()+ router.Handler().ServeHTTP(rec, req)++ if rec.Code != http.StatusNotFound {+ t.Fatalf("expected 404 for an unbound report-only token, got %d", rec.Code)+ }+}