Skip to content

Commit e335f53

Browse files
nashluffymluffmannikola-jokic
authored
Add response body to error when fetching access token (#4005)
Co-authored-by: mluffman <[email protected]> Co-authored-by: Nikola Jokic <[email protected]>
1 parent c359d14 commit e335f53

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

github/actions/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1060,10 +1060,15 @@ func (c *Client) fetchAccessToken(ctx context.Context, gitHubConfigURL string, c
10601060
defer resp.Body.Close()
10611061

10621062
if resp.StatusCode != http.StatusCreated {
1063+
errMsg := fmt.Sprintf("failed to get access token for GitHub App auth (%v)", resp.Status)
1064+
if body, err := io.ReadAll(resp.Body); err == nil {
1065+
errMsg = fmt.Sprintf("%s: %s", errMsg, string(body))
1066+
}
1067+
10631068
return nil, &GitHubAPIError{
10641069
StatusCode: resp.StatusCode,
10651070
RequestID: resp.Header.Get(HeaderGitHubRequestID),
1066-
Err: fmt.Errorf("failed to get access token for GitHub App auth: %v", resp.Status),
1071+
Err: errors.New(errMsg),
10671072
}
10681073
}
10691074

0 commit comments

Comments
 (0)