From 7aee0deb38eaa1bf09ba66e0e22a245d21e1292b Mon Sep 17 00:00:00 2001 From: Alexander Emelin Date: Wed, 2 Jun 2021 18:02:54 +0300 Subject: [PATCH] live: log error on dashboard subscribe (#35095) --- pkg/services/live/features/dashboard.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/services/live/features/dashboard.go b/pkg/services/live/features/dashboard.go index ecd33d204cd..54f1029580b 100644 --- a/pkg/services/live/features/dashboard.go +++ b/pkg/services/live/features/dashboard.go @@ -47,7 +47,7 @@ func (h *DashboardHandler) GetHandlerForPath(path string) (models.ChannelHandler } // OnSubscribe for now allows anyone to subscribe to any dashboard -func (h *DashboardHandler) OnSubscribe(ctx context.Context, user *models.SignedInUser, e models.SubscribeEvent) (models.SubscribeReply, backend.SubscribeStreamStatus, error) { +func (h *DashboardHandler) OnSubscribe(_ context.Context, user *models.SignedInUser, e models.SubscribeEvent) (models.SubscribeReply, backend.SubscribeStreamStatus, error) { parts := strings.Split(e.Path, "/") if parts[0] == "gitops" { // gitops gets all changes for everything, so lets make sure it is an admin user @@ -63,13 +63,13 @@ func (h *DashboardHandler) OnSubscribe(ctx context.Context, user *models.SignedI if len(parts) == 2 && parts[0] == "uid" { query := models.GetDashboardQuery{Uid: parts[1], OrgId: user.OrgId} if err := bus.Dispatch(&query); err != nil { - logger.Error("Unknown dashboard", "query", query) + logger.Error("Error getting dashboard", "query", query, "error", err) return models.SubscribeReply{}, backend.SubscribeStreamStatusNotFound, nil } dash := query.Result - guardian := guardian.New(dash.Id, user.OrgId, user) - if canView, err := guardian.CanView(); err != nil || !canView { + guard := guardian.New(dash.Id, user.OrgId, user) + if canView, err := guard.CanView(); err != nil || !canView { return models.SubscribeReply{}, backend.SubscribeStreamStatusPermissionDenied, nil }