From a2f842ceea6d1791df40f158e2e8050e002b5bde Mon Sep 17 00:00:00 2001 From: VioletHynes Date: Tue, 26 Mar 2024 15:57:24 -0400 Subject: [PATCH 1/2] VAULT-20403 fix incorrectly deferred resource closure in debug command --- command/debug.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/command/debug.go b/command/debug.go index 09df88fb4d60..8ad7466e5cc3 100644 --- a/command/debug.go +++ b/command/debug.go @@ -687,17 +687,18 @@ func (c *DebugCommand) collectHostInfo(ctx context.Context) { return } if resp != nil { - defer resp.Body.Close() - secret, err := api.ParseSecret(resp.Body) if err != nil { c.captureError("host", err) + resp.Body.Close() return } if secret != nil && secret.Data != nil { hostEntry := secret.Data c.hostInfoCollection = append(c.hostInfoCollection, hostEntry) } + + resp.Body.Close() } } } From 7b7d6391a307cd7dcae1539837764e2004d4b214 Mon Sep 17 00:00:00 2001 From: VioletHynes Date: Tue, 26 Mar 2024 16:01:07 -0400 Subject: [PATCH 2/2] VAULT-20403 changelog --- changelog/26167.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/26167.txt diff --git a/changelog/26167.txt b/changelog/26167.txt new file mode 100644 index 000000000000..f53d18c9fef6 --- /dev/null +++ b/changelog/26167.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli/debug: Fix resource leak in CLI debug command. +``` \ No newline at end of file