Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Python] LRO initial error response #1404

Closed
annatisch opened this issue Sep 6, 2016 · 10 comments
Closed

[Python] LRO initial error response #1404

annatisch opened this issue Sep 6, 2016 · 10 comments
Labels

Comments

@annatisch
Copy link
Member

It seems that if an error occurs during a long running operation, it will either have an exit code of 200/201/202/204 and be deserializable to an object as defined in the swagger, or it will have a generic error code (e.g. 400) and have an error response in a format conforming to the Resource Provider spec.

Is it also expected behaviour to be able to fail with a standard exit code (400) and be able to deserialize that response to a swagger object?

Currently the Python runtime does not accommodate this - do the other languages?

This issue is encountered with the IoT spec documented in the issue here:
Azure/azure-rest-api-specs#488

@annatisch annatisch added the design-discussion An area of design currently under discussion and open to team and community feedback. label Sep 6, 2016
@lmazuel
Copy link
Member

lmazuel commented Sep 12, 2016

To give more details, IoTHub is returning:

{
  "Code" : "IotHubsQuotaExceeded",
  "HttpStatusCode" : "BadRequest",
  "Message" : "Max number of Iot Hubs exceeded for sku = Free, Max Allowed = 1, Current = 2. If you contact a support representative please include this correlation identifier: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, timestamp: 2016-08-24 05:17:41Z, errorcode: IH400019."
}

while other services returns OData v4.0 error message syntax:

{ 
   "error": { 
      "code": "BadArgument", 
      "message": "The provided database ‘foo’ has an invalid username."
  }
}

Based on the RestAPI document I have, MS WebService are supposed to follow OData error message.

So, should we make an exception and support the IoTHub format, or ask the IoTHub team to follow the OData v4.0 convention as everyone else?

Python currently supports OData error message and does not parse message using the IoTHub format.

@amarzavery @tbombach @rkmanda

@xscript
Copy link

xscript commented Sep 21, 2016

Any update? Now command module for IoT in Azure CLI (python) can't display error message from server, which doesn't help user to take proper actions to fix their errors.

@annatisch
Copy link
Member Author

@amarzavery,
If I could just confirm what we discussed when this came up last week - I'm I correct in understanding that according to the schema here:
https://github.com/Azure/azure-rest-api-specs/blob/master/arm-iothub/2016-02-03/swagger/iothub.json#L103

The default error response should be used as higher priority than the OData error object when handling any non-200/201/202/204 exit code on the initial call (i.e. non during polling) - does this sound right?

annatisch added a commit that referenced this issue Sep 23, 2016
tbombach pushed a commit that referenced this issue Sep 28, 2016
* [Python] LRO initial response deserialization

Fix for issue #1404

* Fixed msrestazure setup.py homepage

* Fixed msrest setup.py homepage and enum

Fix for issue #1437
@yugangw-msft
Copy link
Contributor

yugangw-msft commented Sep 28, 2016

Another issue on python LRO deserialization. It appears the 2 fields from LRO error are not being handled. If no specific reasons, we should fix it. Let me know if we need a separate bug.
I found this issue on app service plan creation code, python SDK reports a very generic exception because of this.

@annatisch
Copy link
Member Author

Hi @yugangw-msft,
This error is specifically about poor deserialization on the initial response, as opposed to polling responses - if that's not what you're encountering it would be best to open a new issue.

Which version of msrestazure are you seeing this with? My changes to address this issue have been merged but not yet published, so if it's initial error deserialization that's incorrect you could try grabbing the latest azure_operations.py and seeing if that solves it:
https://github.com/Azure/autorest/blob/master/src/client/Python/msrestazure/msrestazure/azure_operation.py

@yugangw-msft
Copy link
Contributor

It is on the poor deserialization on the initial response, but i would agree this can be tracked as a separate issue. It is a different thing though related.
And yes, I did try out your change yesterday, saw it doesn't work, debugged, and then realized python never sniffed the 'target' and detail fields :-)

@annatisch
Copy link
Member Author

annatisch commented Sep 28, 2016

Woah yeah - I'm pretty sure the Python implementation of CloudError doesn't include Target or Details, so that is certainly a big issue, though agreed, a separate one. Thanks for finding this!!

@yugangw-msft
Copy link
Contributor

Sure, opened #1460. Please let us know when you have a ETA on this
Thanks @annatisch!

@fearthecowboy fearthecowboy removed the design-discussion An area of design currently under discussion and open to team and community feedback. label Oct 13, 2016
@lmazuel
Copy link
Member

lmazuel commented Oct 17, 2016

Initial bug fixed by: #1451
Release soon

@lmazuel
Copy link
Member

lmazuel commented Oct 17, 2016

Released in msrestazure 0.4.4
https://pypi.python.org/pypi/msrestazure/0.4.4

@lmazuel lmazuel closed this as completed Oct 17, 2016
dsgouda pushed a commit to dsgouda/autorest that referenced this issue Oct 28, 2016
* [Python] LRO initial response deserialization

Fix for issue Azure#1404

* Fixed msrestazure setup.py homepage

* Fixed msrest setup.py homepage and enum

Fix for issue Azure#1437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants