Skip to content

Commit

Permalink
Avoid returning 500 when for TRACE_TOO_LARGE
Browse files Browse the repository at this point in the history
  • Loading branch information
zalegrala committed Oct 4, 2024
1 parent 6afedd9 commit a62bf71
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ func (c statusCodeAdjustWare) RoundTrip(req Request) (*http.Response, error) {
// if the frontend issues a bad request then externally we need to represent that as an
// internal error
// exceptions
// 413 - request entity too large
// 429 - too many requests
if resp.StatusCode >= 400 && resp.StatusCode < 500 && resp.StatusCode != 429 {
if resp.StatusCode >= 400 && resp.StatusCode < 500 && resp.StatusCode != 429 && resp.StatusCode != 413 {
resp.StatusCode = http.StatusInternalServerError
resp.Status = http.StatusText(http.StatusInternalServerError)
// leave the body alone. it will preserve the original error message
Expand Down
2 changes: 1 addition & 1 deletion modules/querier/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ func handleError(w http.ResponseWriter, err error) {

// todo: better understand all errors returned from queriers and categorize more as 4XX
if errors.Is(err, trace.ErrTraceTooLarge) {
http.Error(w, err.Error(), http.StatusBadRequest)
http.Error(w, err.Error(), http.StatusRequestEntityTooLarge)
return
}

Expand Down

0 comments on commit a62bf71

Please sign in to comment.