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

[DPG] Cant deserialize xml error response #2921

Open
catalinaperalta opened this issue Nov 15, 2024 · 0 comments
Open

[DPG] Cant deserialize xml error response #2921

catalinaperalta opened this issue Nov 15, 2024 · 0 comments
Assignees

Comments

@catalinaperalta
Copy link
Member

Generated python using this spec: https://github.com/Azure/azure-rest-api-specs/tree/feature/blob-tsp/specification/storage/Microsoft.BlobStorage

While running some tests I noticed that we kept crashing when there was an error from the service. Seems we dont support xml error deserialization.

The line that is causing the error:

error = _deserialize(_models.StorageError, response.json())

Seems like we should be checking the content type in order to deserialize the error correctly.

Example crash:

(blobs) PS C:\Users\caperal\repos\azure-sdk-for-python\sdk\storage\azure-storage-blob\azure\storage\blob\_generated_patched> python .\test_xml.py
Traceback (most recent call last):
  File "C:\Users\caperal\repos\azure-sdk-for-python\sdk\storage\azure-storage-blob\azure\storage\blob\_generated_patched\test_xml.py", line 26, in <module>
    res = client.blob.query(
  File "C:\Users\caperal\repos\azure-sdk-for-python\sdk\core\azure-core\azure\core\tracing\decorator.py", line 105, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "C:\Users\caperal\repos\azure-sdk-for-python\sdk\storage\azure-storage-blob\azure\storage\blob\_generated_patched\azure\storage\blob\operations\_operations.py", line 9816, in query
    error = _deserialize(_models.StorageError, response.json())
  File "C:\Users\caperal\repos\azure-sdk-for-python\sdk\core\azure-core\azure\core\rest\_http_response_impl.py", line 331, in json
    self._json = loads(self.text())
  File "C:\Python310\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Python310\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python310\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants