diff --git a/storage/remote/client.go b/storage/remote/client.go index af696336bd..68891f659e 100644 --- a/storage/remote/client.go +++ b/storage/remote/client.go @@ -384,7 +384,8 @@ func (c *Client) Read(ctx context.Context, query *prompb.Query, sortSeries bool) _ = httpResp.Body.Close() cancel() - err := errors.New(string(body)) + errStr := strings.Trim(string(body), "\n") + err := errors.New(errStr) return nil, fmt.Errorf("remote server %s returned http status %s: %w", c.urlString, httpResp.Status, err) } diff --git a/storage/remote/client_test.go b/storage/remote/client_test.go index 27a322c39f..a9e312ffc8 100644 --- a/storage/remote/client_test.go +++ b/storage/remote/client_test.go @@ -342,7 +342,7 @@ func TestReadClient(t *testing.T) { httpHandler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { http.Error(w, "test error", http.StatusBadRequest) }), - expectedErrorContains: "test error\n", + expectedErrorContains: "test error", unwrap: true, }, }