[v10.4.x] Loki: Fix null pointer exception in case request returned an error (#84401)

Loki: Fix null pointer exception in case request returned an error (#84398)

Loki: Fix nullpointer in case query returned an error
(cherry picked from commit 34f9bff9e0)

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-03-13 19:31:12 +02:00
committed by GitHub
co-authored by Sven Grossmann
parent 1d73820ac7
commit f4a9aa1171
+5
View File
@@ -240,6 +240,11 @@ func executeQuery(ctx context.Context, query *lokiQuery, req *backend.QueryDataR
defer span.End()
queryRes, err := runQuery(ctx, api, query, responseOpts, plog)
if queryRes == nil {
// we always want to return a backend.DataResponse object, even if we received just an error
queryRes = &backend.DataResponse{}
}
if err != nil {
span.RecordError(err)
span.SetStatus(codes.Error, err.Error())