From fa8bf2acba48b7f537fbacb5919c63bf4e5dfaf1 Mon Sep 17 00:00:00 2001 From: talham7391 Date: Mon, 2 Mar 2020 13:28:37 -0500 Subject: [PATCH] Clearer error response from push endpoint when labels are malformed (#1750) * Clearer error response from push endpoint when labels are malformed * Concise error formatting --- pkg/distributor/distributor_test.go | 2 +- pkg/distributor/validator.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/distributor/distributor_test.go b/pkg/distributor/distributor_test.go index 2737348c27..9b3c3ac2d7 100644 --- a/pkg/distributor/distributor_test.go +++ b/pkg/distributor/distributor_test.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) { diff --git a/pkg/distributor/validator.go b/pkg/distributor/validator.go index 933ff52019..25865de3e5 100644 --- a/pkg/distributor/validator.go +++ b/pkg/distributor/validator.go @@ -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) }