From fb11fc7fcf7178f0564db5b73af595d54a8757f8 Mon Sep 17 00:00:00 2001 From: Samuel Dufel Date: Mon, 12 Sep 2022 08:23:10 -0700 Subject: [PATCH] Route parse errors from sharding through normal api path (#5684) 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 Signed-off-by: Samuel Dufel --- pkg/queryfrontend/shard_query.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/queryfrontend/shard_query.go b/pkg/queryfrontend/shard_query.go index b0c8b4cb4f..2109182634 100644 --- a/pkg/queryfrontend/shard_query.go +++ b/pkg/queryfrontend/shard_query.go @@ -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) }