Skip to content

Commit

Permalink
fix response on token error
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyng committed Feb 7, 2024
1 parent b9229ff commit e805ac1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,14 @@ func getAuthToken(ctx context.Context, redirData AuthRedirect) (string, error) {
defer resp.Body.Close()

if resp.StatusCode >= http.StatusBadRequest {
body, _ := io.ReadAll(resp.Body)
return "", fmt.Errorf("on pull registry responded with code %d: %s", resp.StatusCode, body)
responseBody, err := io.ReadAll(resp.Body)
if err != nil {
return "", fmt.Errorf("%d: %v", resp.StatusCode, err)
} else if len(responseBody) > 0 {
return "", fmt.Errorf("%d: %s", resp.StatusCode, responseBody)
}

return "", fmt.Errorf("%s", resp.Status)
}

respBody, err := io.ReadAll(resp.Body)
Expand Down

0 comments on commit e805ac1

Please sign in to comment.