fix(distributor): parseError BadRequest (#975)

When the label validation in the distributor failed, it was reported as 500
Internal Server Error instead of 400 BadRequest. Fixes that.
pull/1001/head
sh0rez 6 years ago committed by GitHub
parent 70ed5feb9d
commit 3467440b30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      pkg/distributor/distributor.go

@ -15,6 +15,7 @@ import (
opentracing "github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/weaveworks/common/httpgrpc"
"github.com/weaveworks/common/user"
"google.golang.org/grpc/health/grpc_health_v1"
@ -221,9 +222,10 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
func (d *Distributor) validateLabels(userID, labels string) error {
ls, err := util.ToClientLabels(labels)
if err != nil {
return err
return httpgrpc.Errorf(http.StatusBadRequest, err.Error())
}
// everything in `ValidateLabels` returns `httpgrpc.Errorf` errors, no sugaring needed
return validation.ValidateLabels(d.overrides, userID, ls)
}

Loading…
Cancel
Save