Strip newline in error when reading from remote client (#16487)

Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
pull/16494/head
zenador 2 months ago committed by GitHub
parent 5630a3906a
commit d73b0f34e3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      storage/remote/client.go
  2. 2
      storage/remote/client_test.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)
}

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

Loading…
Cancel
Save