Skip to content

Commit

Permalink
Include more data when we fail to fetch a token
Browse files Browse the repository at this point in the history
Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Jun 20, 2024
1 parent b980610 commit 2044bb9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docker/docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,12 @@ func newBearerTokenFromHTTPResponseBody(res *http.Response) (*bearerToken, error

token := new(bearerToken)
if err := json.Unmarshal(blob, &token); err != nil {
return nil, err
const bodySampleLength = 50
bodySample := blob
if len(bodySample) > bodySampleLength {
bodySample = bodySample[:bodySampleLength]
}
return nil, fmt.Errorf("decoding bearer token (last URL %q, body start %q): %w", res.Request.URL.Redacted(), string(bodySample), err)
}
if token.Token == "" {
token.Token = token.AccessToken
Expand Down

0 comments on commit 2044bb9

Please sign in to comment.