From 100aa47a43ce8dec588d7ee0e9c67885d81d8e77 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Tue, 1 Aug 2023 13:39:16 +0200 Subject: [PATCH] sdk/client: fixing an issue when parsing the OData from the API Response Databricks @ 2023-02-01 returns a literal empty string from the initial Delete operation: https://github.com/hashicorp/go-azure-sdk/issues/436 --- sdk/client/client.go | 7 +++---- sdk/client/resourcemanager/poller_delete.go | 12 ++++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/sdk/client/client.go b/sdk/client/client.go index 01523e054ad..9d9a79b8a8a 100644 --- a/sdk/client/client.go +++ b/sdk/client/client.go @@ -352,10 +352,9 @@ func (c *Client) Execute(ctx context.Context, req *Request) (*Response, error) { return true, nil } - o, err := odata.FromResponse(r) - if err != nil { - return false, err - } + // Extract OData from response, intentionally ignoring any errors as it's not crucial to extract + // valid OData at this point (valid json can still error here, such as any non-object literal) + o, _ := odata.FromResponse(r) if f := req.RetryFunc; f != nil { shouldRetry, err := f(r, o) diff --git a/sdk/client/resourcemanager/poller_delete.go b/sdk/client/resourcemanager/poller_delete.go index f6c8bb45e09..0c40848fa62 100644 --- a/sdk/client/resourcemanager/poller_delete.go +++ b/sdk/client/resourcemanager/poller_delete.go @@ -88,12 +88,16 @@ func (p deletePoller) Poll(ctx context.Context) (result *pollers.PollResult, err if resp.Response != nil { switch resp.StatusCode { case http.StatusNotFound: - result.Status = pollers.PollingStatusSucceeded - return + { + result.Status = pollers.PollingStatusSucceeded + return + } case http.StatusOK: - result.Status = pollers.PollingStatusInProgress - return + { + result.Status = pollers.PollingStatusInProgress + return + } } err = fmt.Errorf("unexpected status code when polling for resource after deletion, expected a 200/204 but got %d", resp.StatusCode)