diff --git a/backend/internal/api/alerts.go b/backend/internal/api/alerts.go index 81ed9ef..2ee4241 100644 --- a/backend/internal/api/alerts.go +++ b/backend/internal/api/alerts.go @@ -5,6 +5,8 @@ import ( "net/http" "strconv" + "flowsight/internal/store" + "github.com/go-chi/chi/v5" ) @@ -15,6 +17,9 @@ func (s *Server) ListAlerts(w http.ResponseWriter, r *http.Request) { writeErr(w, http.StatusBadGateway, "db: "+err.Error()) return } + if rows == nil { + rows = []store.Alert{} + } writeJSON(w, http.StatusOK, map[string]any{"alerts": rows}) } @@ -72,5 +77,8 @@ func (s *Server) AlertEvents(w http.ResponseWriter, r *http.Request) { writeErr(w, http.StatusBadGateway, "db: "+err.Error()) return } + if evts == nil { + evts = []map[string]any{} + } writeJSON(w, http.StatusOK, map[string]any{"events": evts}) } diff --git a/backend/internal/api/routines.go b/backend/internal/api/routines.go index 5efb38c..6f05fc3 100644 --- a/backend/internal/api/routines.go +++ b/backend/internal/api/routines.go @@ -101,6 +101,9 @@ func (s *Server) RunHistory(w http.ResponseWriter, r *http.Request) { writeErr(w, http.StatusBadGateway, "db: "+err.Error()) return } + if hist == nil { + hist = []map[string]any{} + } writeJSON(w, http.StatusOK, map[string]any{"runs": hist}) }