mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 14:17:12 +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()
|
_ = httpResp.Body.Close()
|
||||||
|
|
||||||
cancel()
|
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)
|
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) {
|
httpHandler: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
http.Error(w, "test error", http.StatusBadRequest)
|
http.Error(w, "test error", http.StatusBadRequest)
|
||||||
}),
|
}),
|
||||||
expectedErrorContains: "test error\n",
|
expectedErrorContains: "test error",
|
||||||
unwrap: true,
|
unwrap: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user