LibraryPanels: Fix folderUid nil pointer dereference (#93400)

This commit is contained in:
kay delaney
2024-09-17 13:03:49 +00:00
committed by GitHub
parent 4d50cb2b7b
commit cbf2aa993e
+3 -3
View File
@@ -145,7 +145,7 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.LibraryElements).Inc()
// folderUID *string will be changed to string
var folderUID string
var folderUID = ""
if cmd.FolderUID != nil {
folderUID = *cmd.FolderUID
}
@@ -172,9 +172,9 @@ func (l *LibraryElementService) createLibraryElement(c context.Context, signedIn
err = l.SQLStore.WithTransactionalDbSession(c, func(session *db.Session) error {
if l.features.IsEnabled(c, featuremgmt.FlagLibraryPanelRBAC) {
allowed, err := l.AccessControl.Evaluate(c, signedInUser, ac.EvalPermission(ActionLibraryPanelsCreate, dashboards.ScopeFoldersProvider.GetResourceScopeUID(*cmd.FolderUID)))
allowed, err := l.AccessControl.Evaluate(c, signedInUser, ac.EvalPermission(ActionLibraryPanelsCreate, dashboards.ScopeFoldersProvider.GetResourceScopeUID(folderUID)))
if !allowed {
return fmt.Errorf("insufficient permissions for creating library panel in folder with UID %s", *cmd.FolderUID)
return fmt.Errorf("insufficient permissions for creating library panel in folder with UID %s", folderUID)
}
if err != nil {
return err