diff --git a/pkg/cmd/attestation/download/metadata.go b/pkg/cmd/attestation/download/metadata.go index 49b152859..4b2c0e9d1 100644 --- a/pkg/cmd/attestation/download/metadata.go +++ b/pkg/cmd/attestation/download/metadata.go @@ -39,6 +39,9 @@ func (s *LiveStore) createMetadataFile(artifactDigest string, attestationsResp [ bundle := resp.Bundle attBytes, err := json.Marshal(bundle) if err != nil { + if err = f.Close(); err != nil { + return "", errors.Join(ErrAttestationFileCreation, fmt.Errorf("failed to close file while marshalling JSON: %w", err)) + } return "", errors.Join(ErrAttestationFileCreation, fmt.Errorf("failed to marshall attestation to JSON while writing to file: %w", err)) }