From e2991f39323b8abe88ac484d9d5b045345c2ed21 Mon Sep 17 00:00:00 2001
From: Gwen Le Bihan <hey@ewen.works>
Date: Tue, 4 Feb 2025 18:37:31 +0100
Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Show=20request=20body=20too=20when?=
 =?UTF-8?q?=20api=20error=20in=20upsertGithubRepo?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 main.go | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/main.go b/main.go
index 0d45836..786e88c 100644
--- a/main.go
+++ b/main.go
@@ -304,8 +304,9 @@ func upsertGitHubRepo(repo map[string]interface{}, mirrorConfigUsed MirrorDefini
 	defer resp.Body.Close()
 
 	if resp.StatusCode >= 400 {
-		body, _ := io.ReadAll(resp.Body)
-		return "", fmt.Errorf("GitHub API error: %s: %s", resp.Status, body)
+		respBody, _ := io.ReadAll(resp.Body)
+		reqBody, _ := io.ReadAll(req.Body)
+		return "", fmt.Errorf("GitHub API error: %s: %s: for request: %s", resp.Status, respBody, reqBody)
 	}
 
 	return path, nil
-- 
GitLab