diff --git a/pkg/keymanagementprovider/azurekeyvault/provider.go b/pkg/keymanagementprovider/azurekeyvault/provider.go index 5d6cedad1..0f23f88b1 100644 --- a/pkg/keymanagementprovider/azurekeyvault/provider.go +++ b/pkg/keymanagementprovider/azurekeyvault/provider.go @@ -459,16 +459,17 @@ func isSecretDisabledError(err error) bool { const SecretDisabledCode = "SecretDisabled" var httpErr *azcore.ResponseError if errors.As(err, &httpErr) { - if httpErr.StatusCode == http.StatusForbidden { - var azureError AzureError - errorResponseBody, readErr := io.ReadAll(httpErr.RawResponse.Body) - if readErr != nil { - return false - } - jsonErr := json.Unmarshal(errorResponseBody, &azureError) - if jsonErr == nil && azureError.Error.Code == ErrorCodeForbidden && azureError.Error.InnerError.Code == SecretDisabledCode { - return true - } + if httpErr.StatusCode != http.StatusForbidden { + return false + } + var azureError AzureError + errorResponseBody, readErr := io.ReadAll(httpErr.RawResponse.Body) + if readErr != nil { + return false + } + jsonErr := json.Unmarshal(errorResponseBody, &azureError) + if jsonErr == nil && azureError.Error.Code == ErrorCodeForbidden && azureError.Error.InnerError.Code == SecretDisabledCode { + return true } }