Skip to content

Commit

Permalink
populate empty resonse for IndexStatsResponse and VolumeResponse (#11209
Browse files Browse the repository at this point in the history
)

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 265018b)
  • Loading branch information
owen-d authored and trevorwhitney committed Nov 13, 2023
1 parent 968f37b commit e9b797f
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 e9b797f

Please sign in to comment.