Skip to content

Commit

Permalink
Fixes 500 in the frontend when a query is invalid.
Browse files Browse the repository at this point in the history
It should be 400 and was recently introduced by cortexproject#4464.

Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
  • Loading branch information
cyriltovena committed Sep 21, 2021
1 parent 67c0985 commit a8add9f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/querier/queryrange/split_by_interval.go
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a8add9f

Please sign in to comment.