question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IoTHubRegistryManager.query_iot_hub throws msrest.exceptions.DeserializationError

See original GitHub issue

Using the azure-iot-hub 2.0.0 on MacOS 10.14.6 with Python 3.6.4 I ran into the above issue details below.

Steps to reproduce:

from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.protocol.models import QuerySpecification


iotrm = IoTHubRegistryManager(MY_CONNECTION_STRING)
q = QuerySpecification(query="SELECT * FROM devices")
iotrm.query_iot_hub(q)

Result:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/azure/iot/hub/iothub_registry_manager.py", line 488, in query_iot_hub
    return self.protocol.service.query_iot_hub(query_specification)
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/azure/iot/hub/protocol/operations/service_operations.py", line 614, in query_iot_hub
    deserialized = self._deserialize("QueryResult", response)
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1233, in __call__
    return self._deserialize(target_obj, data)
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1303, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/exceptions.py", line 51, in raise_with_traceback
    raise error.with_traceback(exc_traceback)
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1293, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1064, in rest_key_extractor
    return working_data.get(key)
msrest.exceptions.DeserializationError: Unable to deserialize to object: type, AttributeError: 'list' object has no attribute 'get'

Expected Result: A QueryResult containing the devices in the IoTHub.

If I run the following:

from azure.iot.hub import IoTHubRegistryManager
from azure.iot.hub.protocol.models import QuerySpecification


iotrm = IoTHubRegistryManager(MY_CONNECTION_STRING)
q = QuerySpecification(query="SELECT * FROM devices")
service = iotrm.protocol.service
url = service.query_iot_hub.metadata["url"]
query_parameters = {}
query_parameters["api-version"] = service._serialize.query("self.api_version", service.api_version, "str")
header_parameters = {}
header_parameters["Accept"] = "application/json"
header_parameters["Content-Type"] = "application/json; charset=utf-8"
body_content = service._serialize.body(q, "QuerySpecification")
request = service._client.post(url, query_parameters, header_parameters, body_content)
response = service._client.send(request, stream=False, **{})
response.status_code
# 200
response.content
# b'[LIST OF DEVICES THAT I EXPECT]'

service._deserialize("QueryResult", response)

Traceback (most recent call last):
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1293, in _deserialize
    found_value = key_extractor(attr, attr_desc, data)
  File "/Users/cappie/.local/share/virtualenvs/django-api-lC7sxAe1/lib/python3.6/site-packages/msrest/serialization.py", line 1064, in rest_key_extractor
    return working_data.get(key)
AttributeError: 'list' object has no attribute 'get'

So something is wrong with the deserializer that the ServiceOperations class uses when it is deserializing a “QueryResult”

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cartertinneycommented, Dec 18, 2019

We have replicated and identified the problem, and are working to fix it as soon as possible

0reactions
az-iot-builder-01commented, Feb 6, 2020

@capfish, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey

Read more comments on GitHub >

github_iconTop Results From Across the Web

azure.iot.hub.IoTHubRegistryManager class | Microsoft Learn
A class to provide convenience APIs for IoTHub Registry Manager operations, based on top of the auto generated IotHub REST APIs.
Read more >
IoTHubRegistryManager.query_iot_hub throws msrest ...
IoTHubRegistryManager.query_iot_hub throws msrest.exceptions.DeserializationError #859. OS and version used: Windows 10 Python version: 3.9.1 pip version: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found