mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
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:
committed by
GitHub
parent
ee9b46fe08
commit
c49170b6b3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user