Skip to content

Commit

Permalink
[k174] populate empty resonse for IndexStatsResponse and VolumeRespon…
Browse files Browse the repository at this point in the history
…se (#11224)

Backport 265018b from #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.

Co-authored-by: Owen Diehl <[email protected]>
  • Loading branch information
trevorwhitney and owen-d authored Nov 13, 2023
1 parent 968f37b commit 82e0183
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Empty file.
8 changes: 6 additions & 2 deletions pkg/querier/queryrange/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 82e0183

Please sign in to comment.