mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-05 21:57:09 +02:00
Strip newline in error when reading from remote client (#16487)
Signed-off-by: Jeanette Tan <jeanette.tan@grafana.com>
This commit is contained in:
parent
5630a3906a
commit
d73b0f34e3
@ -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…
Reference in New Issue
Block a user