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
Fix self-hosted community entitlements reporting expired state
rcourtman770cceae5280
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.goindex 1609f23c00..9f8c526602 100644--- a/internal/api/contract_test.go+++ b/internal/api/contract_test.go@@ -5479,6 +5479,64 @@ func TestContract_EntitlementPayloadMonitoredSystemUsageJSONSnapshot(t *testing.assertJSONSnapshot(t, got, want)}+func TestContract_SelfHostedCommunityEntitlementsJSONSnapshot(t *testing.T) {+ baseDir := t.TempDir()+ mtp := config.NewMultiTenantPersistence(baseDir)+ handlers := NewLicenseHandlers(mtp, false)++ req := httptest.NewRequest(http.MethodGet, "/api/license/entitlements", nil).+ WithContext(context.WithValue(context.Background(), OrgIDContextKey, "default"))+ rec := httptest.NewRecorder()+ handlers.HandleEntitlements(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("entitlements status=%d, want %d: %s", rec.Code, http.StatusOK, rec.Body.String())+ }++ var payload EntitlementPayload+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {+ t.Fatalf("decode entitlements: %v", err)+ }++ got, err := json.Marshal(payload)+ if err != nil {+ t.Fatalf("marshal entitlements payload: %v", err)+ }++ const want = `{+ "capabilities":["update_alerts","sso","ai_patrol"],+ "limits":[],+ "subscription_state":"active",+ "upgrade_reasons":[+ {"key":"mobile_app","reason":"Get Relay so you can check Pulse from your phone when you are away from the dashboard.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=mobile_app"},+ {"key":"push_notifications","reason":"Get Relay so important alerts reach you immediately on mobile instead of waiting for you to reopen Pulse.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=push_notifications"},+ {"key":"relay","reason":"Get Relay so Pulse stays reachable securely from anywhere instead of only on the local dashboard.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=relay"},+ {"key":"long_term_metrics","reason":"Get Relay for 14 days of history, or Pro for 90 days, so you can see what changed before and after an incident.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=long_term_metrics"},+ {"key":"ai_autofix","reason":"Upgrade to Pro so Pulse can move from finding issues to applying safe remediation with your approval or in autonomous mode.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=ai_autofix"},+ {"key":"ai_alerts","reason":"Upgrade to Pro so alerts arrive with root-cause analysis instead of a stack of symptoms.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=ai_alerts"},+ {"key":"kubernetes_ai","reason":"Upgrade to Pro so Pulse can explain cluster pressure, failing pods, and likely causes without manual Kubernetes triage.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=kubernetes_ai"},+ {"key":"rbac","reason":"Upgrade to Pro when more than one operator needs safe access boundaries around infrastructure changes.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=rbac"},+ {"key":"agent_profiles","reason":"Upgrade to Pro to standardize agent behavior across systems without reconfiguring every install by hand.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=agent_profiles"},+ {"key":"advanced_sso","reason":"Upgrade to Pro to connect your identity provider and keep operator access aligned with your existing auth controls.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=advanced_sso"},+ {"key":"audit_logging","reason":"Upgrade to Pro to keep a trustworthy action trail for incident review, accountability, and compliance.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=audit_logging"},+ {"key":"advanced_reporting","reason":"Upgrade to Pro to turn live infrastructure state into shareable reports without manual screenshot work.","action_url":"https://pulserelay.pro/pricing?utm_source=pulse\u0026utm_medium=app\u0026utm_campaign=upgrade\u0026feature=advanced_reporting"}+ ],+ "tier":"free",+ "hosted_mode":false,+ "valid":false,+ "is_lifetime":false,+ "days_remaining":0,+ "trial_eligible":true,+ "max_history_days":7,+ "overflow_days_remaining":14,+ "legacy_connections":{"proxmox_nodes":0,"docker_hosts":0,"kubernetes_clusters":0},+ "has_migration_gap":false,+ "monitored_system_capacity":{"mode":"usage_unavailable","urgency":"ok","current":0,"limit":0,"current_available":false,"available_slots":0,"overage":0,"blocks_new_systems":false,"existing_monitoring_continues":false}+ }`++ assertJSONSnapshot(t, got, want)+}+func TestContract_EntitlementPayloadMonitoredSystemUsageUnavailableJSONSnapshot(t *testing.T) {payload := buildEntitlementPayloadWithUsage(&licenseStatus{Valid: true,diff --git a/internal/api/entitlement_handlers_test.go b/internal/api/entitlement_handlers_test.goindex 7d50cf3b51..68af458188 100644--- a/internal/api/entitlement_handlers_test.go+++ b/internal/api/entitlement_handlers_test.go@@ -565,12 +565,68 @@ func TestEntitlementHandler_TrialEligibility_FreshOrgAllowed(t *testing.T) {if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {t.Fatalf("unmarshal payload failed: %v", err)}+ if payload.SubscriptionState != string(license.SubStateActive) {+ t.Fatalf("subscription_state=%q, want %q", payload.SubscriptionState, license.SubStateActive)+ }if !payload.TrialEligible {t.Fatalf("trial_eligible=%v, want true", payload.TrialEligible)}if payload.TrialEligibilityReason != "" {t.Fatalf("trial_eligibility_reason=%q, want empty", payload.TrialEligibilityReason)}+ for _, limit := range payload.Limits {+ if limit.Key == "max_monitored_systems" {+ t.Fatalf("expected no max_monitored_systems limit in payload, got %+v", payload.Limits)+ }+ }+ if payload.MonitoredSystemCapacity == nil {+ t.Fatal("expected monitored_system_capacity in payload")+ }+ if payload.MonitoredSystemCapacity.Limit != 0 || payload.MonitoredSystemCapacity.BlocksNewSystems {+ t.Fatalf(+ "expected uncapped monitored_system_capacity for fresh community org, got %+v",+ payload.MonitoredSystemCapacity,+ )+ }+}++func TestEntitlementHandler_OverflowOnlyBillingStateReportsActiveCommunity(t *testing.T) {+ baseDir := t.TempDir()+ mtp := config.NewMultiTenantPersistence(baseDir)+ now := time.Now().Unix()+ store := config.NewFileBillingStore(baseDir)+ if err := store.SaveBillingState("default", &entitlements.BillingState{+ Capabilities: []string{},+ Limits: map[string]int64{},+ MetersEnabled: []string{},+ OverflowGrantedAt: &now,+ }); err != nil {+ t.Fatalf("SaveBillingState: %v", err)+ }++ h := NewLicenseHandlers(mtp, false)+ ctx := context.WithValue(context.Background(), OrgIDContextKey, "default")+ req := httptest.NewRequest(http.MethodGet, "/api/license/entitlements", nil).WithContext(ctx)+ rec := httptest.NewRecorder()+ h.HandleEntitlements(rec, req)++ if rec.Code != http.StatusOK {+ t.Fatalf("status=%d, want %d: %s", rec.Code, http.StatusOK, rec.Body.String())+ }++ var payload EntitlementPayload+ if err := json.Unmarshal(rec.Body.Bytes(), &payload); err != nil {+ t.Fatalf("unmarshal payload failed: %v", err)+ }+ if payload.SubscriptionState != string(license.SubStateActive) {+ t.Fatalf("subscription_state=%q, want %q", payload.SubscriptionState, license.SubStateActive)+ }+ if !payload.TrialEligible {+ t.Fatalf("trial_eligible=%v, want true", payload.TrialEligible)+ }+ if payload.MonitoredSystemCapacity == nil || payload.MonitoredSystemCapacity.Limit != 0 || payload.MonitoredSystemCapacity.BlocksNewSystems {+ t.Fatalf("expected uncapped monitored_system_capacity, got %+v", payload.MonitoredSystemCapacity)+ }}func TestEntitlementHandler_DevModeMirrorsFeatureGateCapabilities(t *testing.T) {diff --git a/internal/api/subscription_entitlements.go b/internal/api/subscription_entitlements.goindex eeb2145899..587c9d34e8 100644--- a/internal/api/subscription_entitlements.go+++ b/internal/api/subscription_entitlements.go@@ -51,7 +51,12 @@ func (h *LicenseHandlers) buildCommercialEntitlementPayload(}}- payload := buildEntitlementPayloadWithUsage(status, svc.SubscriptionState(), usage, trialEndsAtUnix)+ payload := buildEntitlementPayloadWithUsage(+ status,+ h.payloadSubscriptionStateForService(svc),+ usage,+ trialEndsAtUnix,+ )// Surface overflow days remaining for frontend messaging.if days := overflowDaysRemainingFromLicensing(status.Tier, overflowGrantedAt, now); days > 0 {@@ -133,7 +138,11 @@ func (h *LicenseHandlers) HandleRuntimeCapabilities(w http.ResponseWriter, r *ht}}- payload := buildRuntimeCapabilitiesPayloadWithUsage(status, svc.SubscriptionState(), usage)+ payload := buildRuntimeCapabilitiesPayloadWithUsage(+ status,+ h.payloadSubscriptionStateForService(svc),+ usage,+ )payload.HostedMode = h != nil && h.hostedModeif h != nil && h.cfg != nil && h.cfg.DemoMode {payload = sanitizeRuntimeCapabilitiesPayloadForPublicDemo(payload)@@ -143,6 +152,19 @@ func (h *LicenseHandlers) HandleRuntimeCapabilities(w http.ResponseWriter, r *htjson.NewEncoder(w).Encode(payload)}+func (h *LicenseHandlers) payloadSubscriptionStateForService(svc *licenseService) string {+ if svc == nil {+ return ""+ }+ if svc.Current() == nil && svc.Evaluator() == nil && h != nil && !h.hostedMode {+ // Self-hosted community installs have no commercial lifecycle source at+ // all. Report the runtime posture as active community instead of an+ // expired paid subscription.+ return string(subscriptionStateActiveValue)+ }+ return svc.SubscriptionState()+}+func trialEndsAtUnixFromService(svc *licenseService) *int64 {if svc == nil {return nil