Azure / autorest.python

Extension for AutoRest (https://github.com/Azure/autorest) that generates Python code
MIT License
79 stars 57 forks source link

Fix deserialization error for LRO which has discriminator #2589

Closed msyyc closed 3 months ago

msyyc commented 4 months ago

fixes https://github.com/Azure/autorest.python/issues/2428

There are some new findings for legacy test when I mark initial operation as stream operation:

  1. When LRO succeeds in first call, if will fail if use pipeline_response to deserialize since its context is null. One possible solution is to use pipeline_response.http_response which works both for sync and async.

  2. When LRO needs poll, azure-core will set stream=false by default for poll request, so lro works as before.

  3. for async initial, we need call response.load_body() for normal response otherwise the following error happens: image

  4. for async initial, we need call response.load_body() for error response otherwise the following error happens for test case test_sads_put_non_retry. However sync needn't:

image

  1. version-tolerant and legacy use different HttpResponse type
mode HttpResponse type .read() .load_body() .stream_download() .iter_bytes()
leagcy (sync) azure.core.pipeline.transport.RequestsTransportResponse No No Yes No
leagcy (async) azure.core.pipeline.transport.AioHttpTransportResponse No Yes Yes No
vesion-tolerant (sync/async) azure.core.rest.HttpResponse/AsyncHttpResponse Yes No No Yes
msyyc commented 4 months ago
image

https://dev.azure.com/azure-sdk/29ec6040-b234-4e31-b139-33dc4287b756/_apis/build/builds/3803167/logs/534

msyyc commented 3 months ago

move to https://github.com/Azure/autorest.python/pull/2628