From 8ab8ce609b26c278baf2cb6a8dbf40ad1a13eb67 Mon Sep 17 00:00:00 2001 From: idafurjes <36131195+idafurjes@users.noreply.github.com> Date: Thu, 16 Jun 2022 13:13:58 +0200 Subject: [PATCH] Bug: Fix delete dashboard snapshot for deleted dashboards (#50919) * Bug: Fix delete dashboard snapshot for deleted dashboards * Fix lint and make it work for all the errors * Fix lint --- pkg/api/dashboard_snapshot.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/api/dashboard_snapshot.go b/pkg/api/dashboard_snapshot.go index c69140be74a..b2161db9327 100644 --- a/pkg/api/dashboard_snapshot.go +++ b/pkg/api/dashboard_snapshot.go @@ -3,6 +3,7 @@ package api import ( "bytes" "encoding/json" + "errors" "fmt" "net/http" "time" @@ -269,11 +270,12 @@ func (hs *HTTPServer) DeleteDashboardSnapshot(c *models.ReqContext) response.Res guardian := guardian.New(c.Req.Context(), dashboardID, c.OrgId, c.SignedInUser) canEdit, err := guardian.CanEdit() - if err != nil { + // check for permissions only if the dahboard is found + if err != nil && !errors.Is(err, models.ErrDashboardNotFound) { return response.Error(500, "Error while checking permissions for snapshot", err) } - if !canEdit && query.Result.UserId != c.SignedInUser.UserId { + if !canEdit && query.Result.UserId != c.SignedInUser.UserId && !errors.Is(err, models.ErrDashboardNotFound) { return response.Error(403, "Access denied to this snapshot", nil) }