From 5365c92ffa4b225b4650600ff79652b977263568 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Sat, 15 Aug 2026 17:17:16 -0700 Subject: [PATCH] Validate panels in Store.AddPanel/UpdatePanel, not just at the handler CreateDashboard's inline panel-creation path already called validatePanel before insert; AddPanel and UpdatePanel relied on the HTTP handler to validate first instead of enforcing it themselves. Found via a live Postgres integration test: calling store.AddPanel directly (bypassing the handler) hit a viz_config NOT NULL constraint violation instead of getting the same default-empty-JSON treatment every other panel-creation path gets. --- api/dashboards/store.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/dashboards/store.go b/api/dashboards/store.go index 331249b..39bc87f 100644 --- a/api/dashboards/store.go +++ b/api/dashboards/store.go @@ -183,6 +183,9 @@ func (s *Store) DeleteDashboard(ctx context.Context, tenantID, id string) error } func (s *Store) AddPanel(ctx context.Context, tenantID, dashboardID string, p *Panel) error { + if err := validatePanel(p); err != nil { + return err + } ok, err := s.dashboardTenantMatches(ctx, tenantID, dashboardID) if err != nil { return err @@ -203,6 +206,9 @@ func (s *Store) AddPanel(ctx context.Context, tenantID, dashboardID string, p *P } func (s *Store) UpdatePanel(ctx context.Context, tenantID string, p *Panel) error { + if err := validatePanel(p); err != nil { + return err + } ok, err := s.dashboardTenantMatches(ctx, tenantID, p.DashboardID) if err != nil { return err