From e335f530372e4bb890d02bb254423c256a0603ae Mon Sep 17 00:00:00 2001 From: Nash Luffman Date: Wed, 11 Jun 2025 14:52:38 +0100 Subject: [PATCH] Add response body to error when fetching access token (#4005) Co-authored-by: mluffman Co-authored-by: Nikola Jokic --- github/actions/client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/github/actions/client.go b/github/actions/client.go index 9f6f8886..a527581e 100644 --- a/github/actions/client.go +++ b/github/actions/client.go @@ -1060,10 +1060,15 @@ func (c *Client) fetchAccessToken(ctx context.Context, gitHubConfigURL string, c defer resp.Body.Close() if resp.StatusCode != http.StatusCreated { + errMsg := fmt.Sprintf("failed to get access token for GitHub App auth (%v)", resp.Status) + if body, err := io.ReadAll(resp.Body); err == nil { + errMsg = fmt.Sprintf("%s: %s", errMsg, string(body)) + } + return nil, &GitHubAPIError{ StatusCode: resp.StatusCode, RequestID: resp.Header.Get(HeaderGitHubRequestID), - Err: fmt.Errorf("failed to get access token for GitHub App auth: %v", resp.Status), + Err: errors.New(errMsg), } }