Skip to content

Commit ad18b2b

Browse files
authored
[core] temporarily add back post check to stop network failures (Azure#22989)
1 parent 305a746 commit ad18b2b

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

sdk/core/azure-core/CHANGELOG.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
11
# Release History
22

3-
## 1.22.1 (Unreleased)
4-
5-
### Features Added
6-
7-
### Breaking Changes
3+
## 1.22.1 (2022-02-09)
84

95
### Bugs Fixed
106

11-
### Other Changes
7+
- Limiting `final-state-via` scope to POST until consuming SDKs has been fixed to use this option properly on PUT. #22989
128

13-
## 1.22.0 (2022-02-03)
9+
## 1.22.0 (2022-02-03) [YANKED]
1410

1511
### Features Added
1612

sdk/core/azure-core/azure/core/polling/base_polling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ def get_final_get_url(self, pipeline_response):
237237
_FinalStateViaOption.AZURE_ASYNC_OPERATION_FINAL_STATE,
238238
_FinalStateViaOption.OPERATION_LOCATION_FINAL_STATE
239239
]
240+
and self._request.method == "POST"
240241
):
241242
return None
242243
response = pipeline_response.http_response

sdk/core/azure-core/tests/test_base_polling.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
from azure.core.pipeline import PipelineResponse, Pipeline, PipelineContext
4848
from azure.core.pipeline.transport import HttpTransport
4949

50-
from azure.core.polling.base_polling import LROBasePolling
50+
from azure.core.polling.base_polling import LROBasePolling, OperationResourcePolling
5151
from azure.core.pipeline.policies._utils import _FixedOffset
5252
from utils import request_and_responses_product, REQUESTS_TRANSPORT_RESPONSES, create_transport_response, HTTP_REQUESTS
5353
from azure.core.pipeline._tools import is_rest
@@ -879,3 +879,18 @@ def test_final_get_via_location(port, http_request, deserialization_cb):
879879
)
880880
result = poller.result()
881881
assert result == {"returnedFrom": "locationHeaderUrl"}
882+
883+
# THIS TEST WILL BE REMOVED SOON
884+
"""Weird test, but we are temporarily adding back the POST check in OperationResourcePolling
885+
get_final_get_url. With the test added back, we should not exit on final state via checks and
886+
continue through the rest of the code. Since the rest of the code requires inspection of pipeline_response
887+
and since I don't want to bother with adding a pipeline response object, just check that we get
888+
past the final state via checks
889+
"""
890+
@pytest.mark.parametrize("http_request", HTTP_REQUESTS)
891+
def test_post_check_patch(http_request):
892+
algorithm = OperationResourcePolling(lro_options={"final-state-via": "azure-async-operation"})
893+
algorithm._request = http_request("PUT", "http://fakeurl.com")
894+
with pytest.raises(AttributeError) as ex:
895+
algorithm.get_final_get_url(None)
896+
assert "'NoneType' object has no attribute 'http_response'" in str(ex.value)

0 commit comments

Comments
 (0)