Merge branch 'main' into grafana-git-ui-sync
This commit is contained in:
commit
f57df9df99
25 files changed
+617
-692
No files matched your search
@@ -88,3 +88,7 @@ func ToFolderStatusError(err error) k8sErrors.StatusError {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IsForbidden(err error) bool {
|
||||
return k8sErrors.IsForbidden(err) || errors.Is(err, dashboards.ErrFolderAccessDenied)
|
||||
}
|
||||
@@ -201,6 +201,18 @@ func (hs *HTTPServer) GetDashboard(c *contextmodel.ReqContext) response.Response
|
||||
if errors.Is(err, dashboards.ErrFolderNotFound) {
|
||||
return response.Error(http.StatusNotFound, "Folder not found", err)
|
||||
}
|
||||
if apierrors.IsForbidden(err) {
|
||||
// the dashboard is in a folder the user can't access, so return the dashboard without folder info
|
||||
err = nil
|
||||
queryResult = &folder.Folder{
|
||||
UID: dash.FolderUID,
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
hs.log.Error("Failed to get dashboard folder", "error", err)
|
||||
return response.Error(http.StatusInternalServerError, "Dashboard folder could not be read", err)
|
||||
}
|
||||
|
||||
meta.FolderUid = queryResult.UID
|
||||
meta.FolderTitle = queryResult.Title
|
||||
meta.FolderId = queryResult.ID // nolint:staticcheck
|
||||
|
||||
Reference in new issue
Block a user