Skip to content

Commit 9623c9f

Browse files
authored
Fix panic caused by nil pointer dereference (#6609)
Signed-off-by: Raphael Silva <[email protected]>
1 parent fc6c40d commit 9623c9f

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* [BUGFIX] Compactor: Cleaner would delete bucket index when there is no block in bucket store. #6577
1616
* [BUGFIX] Querier: Fix marshal native histogram with empty bucket when protobuf codec is enabled. #6595
1717
* [BUGFIX] Query Frontend: Fix samples scanned and peak samples query stats when query hits results cache. #6591
18+
* [BUGFIX] Query Frontend: Fix panic caused by nil pointer dereference. #6609
1819

1920
## 1.19.0 in progress
2021

pkg/frontend/v2/frontend_scheduler_worker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func (w *frontendSchedulerWorker) schedulerLoop(loop schedulerpb.SchedulerForFro
291291
req.response <- &frontendv2pb.QueryResultRequest{
292292
HttpResponse: &httpgrpc.HTTPResponse{
293293
Code: http.StatusInternalServerError,
294-
Body: []byte(err.Error()),
294+
Body: []byte(resp.GetError()),
295295
},
296296
}
297297

pkg/frontend/v2/frontend_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package v2
33
import (
44
"context"
55
"net"
6+
"net/http"
67
"strconv"
78
"strings"
89
"sync"
@@ -182,6 +183,18 @@ func TestFrontendEnqueueFailure(t *testing.T) {
182183
require.True(t, strings.Contains(err.Error(), "failed to enqueue request"))
183184
}
184185

186+
func TestFrontendEnqueueInternalError(t *testing.T) {
187+
errorMsg := "Some error"
188+
f, _ := setupFrontend(t, func(f *Frontend, msg *schedulerpb.FrontendToScheduler) *schedulerpb.SchedulerToFrontend {
189+
return &schedulerpb.SchedulerToFrontend{Status: schedulerpb.ERROR, Error: errorMsg}
190+
}, 0)
191+
192+
resp, err := f.RoundTripGRPC(user.InjectOrgID(context.Background(), "test"), &httpgrpc.HTTPRequest{})
193+
require.NoError(t, err)
194+
require.Equal(t, []byte(errorMsg), resp.Body)
195+
require.Equal(t, int32(http.StatusInternalServerError), resp.Code)
196+
}
197+
185198
func TestFrontendCancellation(t *testing.T) {
186199
f, ms := setupFrontend(t, nil, 0)
187200

0 commit comments

Comments
 (0)