From 5150a3527f4c01350c65e5811b9e826b35443cb9 Mon Sep 17 00:00:00 2001 From: Ramon de Klein Date: Wed, 17 Apr 2024 14:42:31 +0200 Subject: [PATCH] Processed review comment --- internal/keystore/azure/error.go | 6 ++++-- internal/keystore/azure/key-vault.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/keystore/azure/error.go b/internal/keystore/azure/error.go index 932a9ad1..3bc148ee 100644 --- a/internal/keystore/azure/error.go +++ b/internal/keystore/azure/error.go @@ -7,6 +7,7 @@ package azure import ( "encoding/json" "errors" + "log/slog" "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) @@ -28,8 +29,9 @@ func transportErrToStatus(err error) (status, error) { if errors.As(err, &rerr) { var errorResponse errorResponse if rerr.RawResponse != nil { - err = json.NewDecoder(rerr.RawResponse.Body).Decode(&errorResponse) - if err != nil { + jsonErr := json.NewDecoder(rerr.RawResponse.Body).Decode(&errorResponse) + if jsonErr != nil { + slog.Error("error deserializing Azure KeyVault error message: %v", jsonErr) return status{}, err } } diff --git a/internal/keystore/azure/key-vault.go b/internal/keystore/azure/key-vault.go index e63c293e..654d0a23 100644 --- a/internal/keystore/azure/key-vault.go +++ b/internal/keystore/azure/key-vault.go @@ -354,7 +354,7 @@ func (s *Store) purgeWithRetry(ctx context.Context, name string, retries int) (s return stat, fmt.Errorf("azure: failed to delete '%s': %s (%s)", name, stat.Message, stat.ErrorCode) } switch { - case stat.StatusCode == http.StatusOK: + case stat.StatusCode == http.StatusOK || stat.StatusCode == http.StatusNotFound: return stat, nil case stat.StatusCode == http.StatusForbidden && stat.ErrorCode == "ForbiddenByPolicy": return stat, nil