From e9b797ff6c2115bc14b63e1ad1093449ab106940 Mon Sep 17 00:00:00 2001 From: Owen Diehl Date: Mon, 13 Nov 2023 10:29:46 -0800 Subject: [PATCH] populate empty resonse for IndexStatsResponse and VolumeResponse (#11209) Fixes a panic when the underlying response struct is accessed but not populated after an out-of-bounds request is short-circuited via `NewEmptyResponse` [here](https://github.com/grafana/loki/blob/main/pkg/querier/queryrange/limits.go#L155-L164). This PR ensures the embedded types are not nil in accordance with the other variants in this function. (cherry picked from commit 265018b7293329241ffe9b7c56f38afb07b6b08f) --- .github/workflows/vulnerability-scan.yml | 0 pkg/querier/queryrange/codec.go | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/vulnerability-scan.yml diff --git a/.github/workflows/vulnerability-scan.yml b/.github/workflows/vulnerability-scan.yml new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/pkg/querier/queryrange/codec.go b/pkg/querier/queryrange/codec.go index e3f1905f54d7c..8571eef4e4071 100644 --- a/pkg/querier/queryrange/codec.go +++ b/pkg/querier/queryrange/codec.go @@ -1607,9 +1607,13 @@ func NewEmptyResponse(r queryrangebase.Request) (queryrangebase.Response, error) }, }, nil case *logproto.IndexStatsRequest: - return &IndexStatsResponse{}, nil + return &IndexStatsResponse{ + Response: &logproto.IndexStatsResponse{}, + }, nil case *logproto.VolumeRequest: - return &VolumeResponse{}, nil + return &VolumeResponse{ + Response: &logproto.VolumeResponse{}, + }, nil default: return nil, fmt.Errorf("unsupported request type %T", req) }