mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: Check JSON data is not nil (#95189)
* Fix: Fix panic when json data are nil * Use Interface() * Feedback Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com> * Need to check inside the if statement --------- Co-authored-by: Eric Leijonmarck <eric.leijonmarck@gmail.com>
This commit is contained in:
parent
6e802e6809
commit
7aeb1adff2
@ -543,10 +543,17 @@ func (s *Service) UpdateDataSource(ctx context.Context, cmd *datasources.UpdateD
|
|||||||
"datasource_uid", dataSource.UID)
|
"datasource_uid", dataSource.UID)
|
||||||
|
|
||||||
if dataSource.JsonData != nil {
|
if dataSource.JsonData != nil {
|
||||||
previousRules := dataSource.JsonData.Get("teamHttpHeaders")
|
previousRules := dataSource.JsonData.Get("teamHttpHeaders").Interface()
|
||||||
if previousRules == nil {
|
if previousRules == nil {
|
||||||
cmd.JsonData.Del("teamHttpHeaders")
|
if cmd.JsonData != nil {
|
||||||
|
cmd.JsonData.Del("teamHttpHeaders")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if cmd.JsonData == nil {
|
||||||
|
// It's fine to instantiate a new JsonData here
|
||||||
|
// Because it's done in the SQLStore.UpdateDataSource anyway
|
||||||
|
cmd.JsonData = simplejson.New()
|
||||||
|
}
|
||||||
cmd.JsonData.Set("teamHttpHeaders", previousRules)
|
cmd.JsonData.Set("teamHttpHeaders", previousRules)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user