Provisioning: Fix failure to save dashboard (#81694)

This commit is contained in:
Sofia Papagiannaki
2024-02-02 09:55:29 +00:00
committed by GitHub
parent ab6aa8fe2f
commit 6f02d193f6
5 changed files with 48 additions and 13 deletions
+4 -4
View File
@@ -827,7 +827,7 @@ func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.Get
err := d.store.WithDbSession(ctx, func(sess *db.Session) error {
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
// nolint:staticcheck
if query.ID == 0 && len(query.UID) == 0 && (query.Title == nil || (query.FolderID == nil && query.FolderUID == "")) {
if query.ID == 0 && len(query.UID) == 0 && (query.Title == nil || (query.FolderID == nil && query.FolderUID == nil)) {
return dashboards.ErrDashboardIdentifierNotSet
}
@@ -838,8 +838,8 @@ func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.Get
mustCols = append(mustCols, "title")
}
if query.FolderUID != "" {
dashboard.FolderUID = query.FolderUID
if query.FolderUID != nil {
dashboard.FolderUID = *query.FolderUID
mustCols = append(mustCols, "folder_uid")
} else if query.FolderID != nil { // nolint:staticcheck
// nolint:staticcheck
@@ -848,7 +848,7 @@ func (d *dashboardStore) GetDashboard(ctx context.Context, query *dashboards.Get
metrics.MFolderIDsServiceCount.WithLabelValues(metrics.Dashboard).Inc()
}
has, err := sess.MustCols(mustCols...).Get(&dashboard)
has, err := sess.MustCols(mustCols...).Nullable("folder_uid").Get(&dashboard)
if err != nil {
return err
} else if !has {