Skip to content

Commit

Permalink
Clearer error response from push endpoint when labels are malformed (#…
Browse files Browse the repository at this point in the history
…1750)

* Clearer error response from push endpoint when labels are malformed

* Concise error formatting
  • Loading branch information
talham7391 authored Mar 2, 2020
1 parent 4da4d74 commit fa8bf2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestDistributor(t *testing.T) {
lines: 100,
mangleLabels: true,
expectedResponse: success,
expectedError: httpgrpc.Errorf(http.StatusBadRequest, "parse error at line 1, col 4: literal not terminated"),
expectedError: httpgrpc.Errorf(http.StatusBadRequest, "error parsing labels: parse error at line 1, col 4: literal not terminated"),
},
} {
t.Run(fmt.Sprintf("[%d](samples=%v)", i, tc.lines), func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/distributor/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (v Validator) ValidateLabels(userID string, labels string) error {
// an orthogonal concept (we need not use ValidateLabels in this context)
// but the upstream cortex_validation pkg uses it, so we keep this
// for parity.
return httpgrpc.Errorf(http.StatusBadRequest, err.Error())
return httpgrpc.Errorf(http.StatusBadRequest, "error parsing labels: %v", err)
}
return cortex_validation.ValidateLabels(v, userID, ls)
}

0 comments on commit fa8bf2a

Please sign in to comment.