[v9.3.x] Plugins: Fix circular reference in customOptions leading to MarshalJSON errors (#62564)
Plugins: Fix circular reference in customOptions leading to MarshalJSON errors (#62328)
* Plugins: test ds.JsonData.MarshalJSON()
* CustomOptions: copy to avoid cyclic marshal
(cherry picked from commit c41f97029e)
Co-authored-by: Yasir Ekinci <ekinci.yasir@gmail.com>
This commit is contained in:
co-authored by
Yasir Ekinci
parent
267d53a56a
commit
aaa2a821ae
@@ -417,7 +417,10 @@ func (s *Service) httpClientOptions(ctx context.Context, ds *datasources.DataSou
|
||||
if ds.JsonData != nil {
|
||||
opts.CustomOptions = ds.JsonData.MustMap()
|
||||
// allow the plugin sdk to get the json data in JSONDataFromHTTPClientOptions
|
||||
opts.CustomOptions["grafanaData"] = ds.JsonData.MustMap()
|
||||
opts.CustomOptions["grafanaData"] = make(map[string]interface{})
|
||||
for k, v := range opts.CustomOptions {
|
||||
opts.CustomOptions[k] = v
|
||||
}
|
||||
}
|
||||
if ds.BasicAuth {
|
||||
password, err := s.DecryptedBasicAuthPassword(ctx, ds)
|
||||
|
||||
@@ -363,6 +363,10 @@ func TestService_GetHttpTransport(t *testing.T) {
|
||||
require.NotNil(t, rt)
|
||||
tr := configuredTransport
|
||||
|
||||
// make sure we can still marshal the JsonData after httpClientOptions (avoid cycles)
|
||||
_, err = ds.JsonData.MarshalJSON()
|
||||
require.NoError(t, err)
|
||||
|
||||
require.False(t, tr.TLSClientConfig.InsecureSkipVerify)
|
||||
require.Len(t, tr.TLSClientConfig.RootCAs.Subjects(), 1)
|
||||
require.Equal(t, "server-name", tr.TLSClientConfig.ServerName)
|
||||
|
||||
Reference in New Issue
Block a user