Bug in asyncio library - message_is_dict

PhilipDAth
Kind of a big deal
Kind of a big deal

Bug in asyncio library - message_is_dict

I'm writing a script using async io, and I keep getting this intermittent error when calling dashboard.wireless.getNetworkWirelessSsid():

 

  File "C:\Users\pid\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\meraki\aio\rest_session.py", line 261, in _request
    action_batch_concurrency_error = {'errors': [
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnboundLocalError: cannot access local variable 'message_is_dict' where it is not associated with a value

 

I've traced it back to this chunk of code in the Python asyncio library:

https://github.com/meraki/dashboard-api-python/blob/main/meraki/aio/rest_session.py#L247

 

It tries to set message_is_dict inside an exception handler:

PhilipDAth_0-1694223580338.png

 

The problem is that goes out of scope as soon as the try handler is finished, so when the following code tries to use that variable, it no longer exists.

https://github.com/meraki/dashboard-api-python/blob/main/meraki/aio/rest_session.py#L265

PhilipDAth_1-1694223648236.png

 

In my particular case, I temporarily hard-coded message_is_dict to true, and then I correctly got this error:

wireless, getNetworkWirelessSsid > https://api.meraki.com/api/v1/networks/N_xxx/wireless/ssids/3 - 400 Bad Request, {'errors': ['This endpoint only supports wireless networks']}
Meraki API error: wireless, getNetworkWirelessSsid - 400 Bad Request, {'errors': ['This endpoint only supports wireless networks']}

 

1 Reply 1
John_on_API
Meraki Employee
Meraki Employee

Hi @PhilipDAth I suspect this was one of the issues solved recently: https://github.com/meraki/dashboard-api-python/issues?q=is%3Aissue+is%3Aclosed

 

Get notified when there are additional replies to this discussion.