From 046eda80d68e63b3e93a7876f9cf5b779c2d3687 Mon Sep 17 00:00:00 2001 From: amlmtl <> Date: Thu, 16 Nov 2023 16:38:03 +0000 Subject: [PATCH] fix: workaround for compression handling bug in the Grafana SDK's HTTP client --- pkg/plugin/plugin.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/plugin/plugin.go b/pkg/plugin/plugin.go index c6ddbba..44d3ab7 100644 --- a/pkg/plugin/plugin.go +++ b/pkg/plugin/plugin.go @@ -413,6 +413,13 @@ func callDiscoveryEndpoint(ctx context.Context, httpClient *http.Client, discove return nil, err } + if request.Header.Get("Accept-Encoding") == "" { + // Grafana (as of version 9.x) contains a bug where it will enable compression by adding an explicit Accept-Encoding header by default if missing, + // but not properly handle decompression of any compressed response. + // The header set explicitly here as a workaround for this bug. + request.Header.Set("Accept-Encoding", "identity") + } + resp, err := httpClient.Do(request) if err != nil { log.DefaultLogger.Error("Unable to receive discovery response.", "error", err)