From 3291733c24b77f666dec7a6b632eec285abef44c Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Tue, 21 Sep 2021 11:40:16 +0200 Subject: [PATCH] Fixes 500 in the frontend when a query is invalid. (#4488) It should be 400 and was recently introduced by #4464. Signed-off-by: Cyril Tovena --- pkg/querier/queryrange/split_by_interval.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/querier/queryrange/split_by_interval.go b/pkg/querier/queryrange/split_by_interval.go index d3f663b07d..3d52fc4cba 100644 --- a/pkg/querier/queryrange/split_by_interval.go +++ b/pkg/querier/queryrange/split_by_interval.go @@ -2,11 +2,13 @@ package queryrange import ( "context" + "net/http" "time" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/prometheus/promql/parser" + "github.com/weaveworks/common/httpgrpc" ) type IntervalFn func(r Request) time.Duration @@ -89,7 +91,7 @@ func splitQuery(r Request, interval time.Duration) ([]Request, error) { func evaluateAtModifierFunction(query string, start, end int64) (string, error) { expr, err := parser.ParseExpr(query) if err != nil { - return "", err + return "", httpgrpc.Errorf(http.StatusBadRequest, "%s", err) } parser.Inspect(expr, func(n parser.Node, _ []parser.Node) error { if selector, ok := n.(*parser.VectorSelector); ok {