diff --git a/internal/maa/patch.go b/internal/maa/patch.go index 5dfed9435..d9ac35b4c 100644 --- a/internal/maa/patch.go +++ b/internal/maa/patch.go @@ -9,6 +9,7 @@ import ( "context" "encoding/base64" "fmt" + "io" "net/http" "github.com/Azure/azure-sdk-for-go/profiles/latest/attestation/attestation" @@ -55,10 +56,11 @@ func (p AzurePolicyPatcher) Patch(ctx context.Context, attestationURL string) er if err != nil { return fmt.Errorf("sending request: %w", err) } - resp.Body.Close() + defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return fmt.Errorf("updating attestation policy: unexpected status code: %s", resp.Status) + body, _ := io.ReadAll(resp.Body) + return fmt.Errorf("updating attestation policy: unexpected status code: %s: %s", resp.Status, string(body)) } return nil