fix(scaletest): handle ignored io.ReadAll error in bridge runner (#22850)

Surface the io.ReadAll error in the error message when an HTTP
request fails with a non-200 status, instead of silently
discarding it.
This commit is contained in:
Mathias Fredriksson
2026-03-23 15:58:14 +02:00
committed by GitHub
parent ee9b46fe08
commit c49170b6b3
+5 -1
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
@@ -230,7 +231,10 @@ func (r *Runner) makeRequest(ctx context.Context, logger slog.Logger, url, token
r.cfg.Metrics.ObserveDuration(duration.Seconds())
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
body, readErr := io.ReadAll(resp.Body)
if readErr != nil {
body = []byte(fmt.Sprintf("<failed to read response body: %s>", readErr))
}
err := xerrors.Errorf("request failed with status %d: %s", resp.StatusCode, string(body))
span.RecordError(err)
return err