Skip to content

Commit

Permalink
fix(distributor): parseError BadRequest (#975)
Browse files Browse the repository at this point in the history
When the label validation in the distributor failed, it was reported as 500
Internal Server Error instead of 400 BadRequest. Fixes that.
  • Loading branch information
sh0rez authored Sep 10, 2019
1 parent 70ed5fe commit 3467440
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/distributor/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 3467440

Please sign in to comment.