From 9184e912680364bd1d76dd45f7ece522b52e47e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20R=C3=BCger?= Date: Fri, 13 Mar 2026 01:14:04 +0100 Subject: [PATCH] fix: defer body.Close() before ReadAll to ensure it runs on read error The defer was placed after io.ReadAll, so if ReadAll returned an error the body would not be closed. Move the defer before the read. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- confluence/api.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/confluence/api.go b/confluence/api.go index 312015e..b54ae97 100644 --- a/confluence/api.go +++ b/confluence/api.go @@ -824,11 +824,12 @@ func newErrorStatusNotOK(request *gopencils.Resource) error { ) } - output, _ := io.ReadAll(request.Raw.Body) defer func() { _ = request.Raw.Body.Close() }() + output, _ := io.ReadAll(request.Raw.Body) + return fmt.Errorf( "the Confluence API returned unexpected status: %v, "+ "output: %q",