VAULT-20403 fix incorrectly deferred resource closure in debug command (#26167)

* VAULT-20403 fix incorrectly deferred resource closure in debug command

* VAULT-20403 changelog
This commit is contained in:
Violet Hynes 2024-03-27 11:15:17 -04:00 committed by GitHub
parent 5fac327dae
commit 2a33300003
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

3
changelog/26167.txt Normal file
View file

@ -0,0 +1,3 @@
```release-note:bug
cli/debug: Fix resource leak in CLI debug command.
```

View file

@ -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()
}
}
}