diff --git a/pkg/services/provisioning/dashboards/file_reader.go b/pkg/services/provisioning/dashboards/file_reader.go index eb3085296fd..c3329e07488 100644 --- a/pkg/services/provisioning/dashboards/file_reader.go +++ b/pkg/services/provisioning/dashboards/file_reader.go @@ -156,13 +156,15 @@ func createWalkFn(fr *fileReader, folderId int64) filepath.WalkFunc { return nil } - // id = 0 indicates ID validation should be avoided before writing to the db. - dash.Dashboard.Id = 0 + if dash.Dashboard.Id != 0 { + fr.log.Error("Cannot provision dashboard. Please remove the id property from the json file") + return nil + } cmd := &models.GetDashboardQuery{Slug: dash.Dashboard.Slug} err = bus.Dispatch(cmd) - // if we dont have the dashboard in the db, save it! + // if we don't have the dashboard in the db, save it! if err == models.ErrDashboardNotFound { fr.log.Debug("saving new dashboard", "file", path) _, err = fr.dashboardRepo.SaveDashboard(dash) @@ -181,6 +183,7 @@ func createWalkFn(fr *fileReader, folderId int64) filepath.WalkFunc { fr.log.Debug("loading dashboard from disk into database.", "file", path) _, err = fr.dashboardRepo.SaveDashboard(dash) + return err } } diff --git a/pkg/services/provisioning/dashboards/types.go b/pkg/services/provisioning/dashboards/types.go index 46ca3c9246e..cf65c65348c 100644 --- a/pkg/services/provisioning/dashboards/types.go +++ b/pkg/services/provisioning/dashboards/types.go @@ -24,6 +24,7 @@ func createDashboardJson(data *simplejson.Json, lastModified time.Time, cfg *Das dash.UpdatedAt = lastModified dash.Overwrite = true dash.OrgId = cfg.OrgId + dash.Dashboard.OrgId = cfg.OrgId dash.Dashboard.FolderId = folderId if !cfg.Editable { dash.Dashboard.Data.Set("editable", cfg.Editable)