Clearer error response from push endpoint when labels are malformed (#1750)

* Clearer error response from push endpoint when labels are malformed

* Concise error formatting
pull/1766/head
talham7391 6 years ago committed by GitHub
parent 4da4d74311
commit fa8bf2acba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      pkg/distributor/distributor_test.go
  2. 2
      pkg/distributor/validator.go

@ -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) {

@ -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)
}

Loading…
Cancel
Save