Skip to content

Commit

Permalink
Check the GRPC message content as well
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Oct 15, 2024
1 parent 7bf55cb commit 7d60b99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion integration/e2e/limits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ func TestQueryLimits(t *testing.T) {
time.Sleep(15 * time.Second)
_, err = client.QueryTrace(tempoUtil.TraceIDToHexString(traceID[:]))
require.ErrorContains(t, err, "trace exceeds max size")
require.ErrorContains(t, err, "failed with response: 500") // confirm frontend returns 500
require.ErrorContains(t, err, "failed with response: 413") // confirm frontend returns 500

_, err = querierClient.QueryTrace(tempoUtil.TraceIDToHexString(traceID[:]))
require.ErrorContains(t, err, "trace exceeds max size")
Expand Down
4 changes: 2 additions & 2 deletions modules/frontend/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
errCanceled = httpgrpc.Errorf(StatusClientClosedRequest, context.Canceled.Error())
errDeadlineExceeded = httpgrpc.Errorf(http.StatusGatewayTimeout, context.DeadlineExceeded.Error())
errRequestEntityTooLarge = httpgrpc.Errorf(http.StatusRequestEntityTooLarge, "http: request body too large")
errTraceTooLarge = httpgrpc.Errorf(http.StatusRequestEntityTooLarge, "body: trace too large")
errTraceTooLarge = httpgrpc.Errorf(http.StatusRequestEntityTooLarge, "http: trace exceeds max size")
)

// handler exists to wrap a roundtripper with an HTTP handler. It wraps all
Expand Down Expand Up @@ -177,5 +177,5 @@ func isRequestBodyTooLarge(err error) bool {
}

func isTraceTooLarge(err error) bool {
return err != nil && strings.Contains(err.Error(), "body: trace exceeds max size")
return err != nil && strings.Contains(err.Error(), "trace exceeds max size")
}
6 changes: 4 additions & 2 deletions modules/querier/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"net/http"
"strings"
"time"

"github.com/golang/protobuf/jsonpb" //nolint:all //deprecated
Expand Down Expand Up @@ -425,8 +426,9 @@ func handleError(w http.ResponseWriter, err error) {
return
}

// todo: better understand all errors returned from queriers and categorize more as 4XX
if errors.Is(err, trace.ErrTraceTooLarge) {
// TODO: better understand all errors returned from queriers and categorize more as 4XX
// NOTE: we receive a GRPC error from the ingesters, and so we need to check the string content of error as well.
if errors.Is(err, trace.ErrTraceTooLarge) || strings.Contains(err.Error(), trace.ErrTraceTooLarge.Error()) {
http.Error(w, err.Error(), http.StatusRequestEntityTooLarge)
return
}
Expand Down

0 comments on commit 7d60b99

Please sign in to comment.