Skip to content

Commit

Permalink
Route parse errors from sharding through normal api path (#5684)
Browse files Browse the repository at this point in the history
When the parser used in the querySharder encounters a parse error,
it returns that error back through to the API without the normal
api error wrapper.  This results in parse errors being sent back
with a 500 response code rather than a 400 response code, and the
UI (thanos ui, grafana) treats errors as a generic server error rather
than a client-side error.

This change breaks out of the sharding middleware and passes the request
along the chain to allow the same error handling to occur for parse errors.

Signed-off-by: Samuel Dufel <[email protected]>

Signed-off-by: Samuel Dufel <[email protected]>
  • Loading branch information
sdufel authored Sep 12, 2022
1 parent 0d659bf commit fb11fc7
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pkg/queryfrontend/shard_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,8 @@ type querySharder struct {

func (s querySharder) Do(ctx context.Context, r queryrange.Request) (queryrange.Response, error) {
analysis, err := s.queryAnalyzer.Analyze(r.GetQuery())
if err != nil {
return nil, err
}

if !analysis.IsShardable() {
if err != nil || !analysis.IsShardable() {
s.queriesTotal.WithLabelValues("false").Inc()
return s.next.Do(ctx, r)
}
Expand Down

0 comments on commit fb11fc7

Please sign in to comment.