Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.63k stars 2.84k forks source link

[uamqp] async management call may return status 4xx and empty data #9306

Closed YijunXieMS closed 4 years ago

YijunXieMS commented 4 years ago

For the following code in EventHubs, sometimes (not very often) it doesn't raise an error but response.get_data() returns an empty dict (not None). When it happens, the status code is 4xx. We haven't seen this with the same call of sync.

response = await mgmt_client.mgmt_request_async(
                    mgmt_msg,
                    constants.READ_OPERATION,
                    op_type=op_type,
                    status_code_field=b"status-code",
                    description_fields=b"status-description",
                )

Try with wrong credential

yunhaoling commented 4 years ago

Investigation: There is almost no difference in sync and async mgmt request implementation in uamqp. From the code I would even conclude that what happens to the async one would happen to the sync one as well.

So probably the most efficient way to handle corner case I'm thinking of is to add checking in EH/SB library unless we can stably reproduce the issue.

------ ref

mgmt request sync impl: https://github.com/Azure/azure-uamqp-python/blob/21e1a63108254251da2ece398c49d7b4ad9cff43/uamqp/mgmt_operation.py#L113-L132

mgmt request async impl: https://github.com/Azure/azure-uamqp-python/blob/21e1a63108254251da2ece398c49d7b4ad9cff43/uamqp/async_ops/mgmt_operation_async.py#L88-L107

@YijunXieMS I'm closing it right now, we can reopen this one in the future if we reproduce the problem or we could create new work item for EH/SB to check mgmt request response.