Comments (6)
@TKIPisalegacycipher, seems that this was caused by this commit: 6d9ada0
message_is_dict
is used in aio/rest_session
but it is never set. In sync code (rest_session
) this variable is set as follows but this code block is missing from aio/rest_session
:
try:
message = response.json()
message_is_dict = True
except ValueError:
message = response.content[:100]
message_is_dict = False
from dashboard-api-python.
Hi @dpnetca are you still running into this issue? I've added debug logging here, so if so can you please provide the full debug log on the latest version of the library? Feel free to redact IDs and serial numbers.
from dashboard-api-python.
yes, tested with 1.36.0, 1.37.1 and 1.37.2 and I still get errors, though it looks like it may be slightly different with 3.17.x from 3.16.x
$ pip list | grep meraki
meraki 1.37.2
traceback:
$ python main.py admin.add
Traceback (most recent call last):
File "/home/xxxxxx/code/py/work/momapy_cli/main.py", line 22, in <module>
asyncio.run(admin_add())
File "/home/xxxxxx/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/home/xxxxxx/.pyenv/versions/3.11.4/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxxxx/.pyenv/versions/3.11.4/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/xxxxxx/code/py/work/momapy_cli/admin/add.py", line 91, in admin_add
results = [await task async for task in tqdm_tasks]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxxxx/code/py/work/momapy_cli/admin/add.py", line 91, in <listcomp>
results = [await task async for task in tqdm_tasks]
^^^^^^^^^^
File "/home/xxxxxx/.pyenv/versions/3.11.4/lib/python3.11/asyncio/tasks.py", line 605, in _wait_for_one
return f.result() # May raise f.exception().
^^^^^^^^^^
File "/home/xxxxxx/code/py/work/momapy_cli/admin/add.py", line 29, in add_org_admin
add_result = await dashboard.organizations.createOrganizationAdmin(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxxxx/code/py/work/momapy_cli/.venv/lib/python3.11/site-packages/meraki/aio/rest_session.py", line 505, in post
async with await self.request(metadata, "POST", url, json=json) as response:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xxxxxx/code/py/work/momapy_cli/.venv/lib/python3.11/site-packages/meraki/aio/rest_session.py", line 134, in request
return await self._request(
^^^^^^^^^^^^^^^^^^^^
File "/home/xxxxxx/code/py/work/momapy_cli/.venv/lib/python3.11/site-packages/meraki/aio/rest_session.py", line 273, in _request
if message_is_dict and 'errors' in message.keys() \
^^^^^^^^^^^^^^^
NameError: name 'message_is_dict' is not defined
from dashboard-api-python.
@TKIPisalegacycipher
Difference seems to be here, in the sync rest_session code for 4xx errors the message_is_dict is being initialized to either true or false
dashboard-api-python/meraki/rest_session.py
Line 270 in 86a5658
try:
message = response.json()
message_is_dict = True
except ValueError:
message = response.content[:100]
message_is_dict = False
However, in the equivalent section in the aio library the message_is_dict is not initialized
try:
message = await response.json(content_type = None)
except aiohttp.client_exceptions.ContentTypeError:
logging.debug(f"message is {message}")
logging.debug(f"message is dict? {isinstance(message, dict)}")
try:
message = (await response.text())[:100]
logging.debug(f"message is {message}")
logging.debug(f"message is dict? {isinstance(message, dict)}")
except:
message = None
manually editing my local copy of tat file to the following and code executes without error:
try:
message = await response.json(content_type=None)
message_is_dict = True
...
from dashboard-api-python.
Sorry for the multiple messages, but one more thing of note. looking back at at the 1.36.0 code before the debug was added I can see message_is_dict was initiated here partially, but missing a few things ( see my added comments) the issue is if the first TRY succeeds (which in my case it is) then message_is_dict
is not initialized. causing the error. if the first fails and hits the exception, then it is set incorrectly in the second try, in this case it would be a string not a dict but that is still set to True should be False:
# 4XX errors
else:
try:
message = await response.json(content_type = None)
# message_is_dict = True should be set here
except aiohttp.client_exceptions.ContentTypeError:
try:
message = (await response.text())[:100]
message_is_dict = True # this should be False not True
except:
message = None
message_is_dict = False
from dashboard-api-python.
quick test and it looks like the issue is resolved with 1.37.3. thank you!!
from dashboard-api-python.
Related Issues (20)
- createOrganizationPolicyObject type not found HOT 3
- function not passing 'type' variable HOT 1
- Early Access Supported Calls HOT 1
- Incorrect kwarg is not logged or rejected HOT 4
- Identity PSKs always return null for expiresAt field HOT 1
- 204-No Content error HOT 1
- Logging level HOT 2
- This library requires Python 3.7 at minimum and your interpreter version is 3.10.0 HOT 1
- aiomeraki.organizations.getOrganizationApiRequests failing after upgrading the SDK from 1.34.0 to 1.36.0 HOT 5
- 'Wireless' object has no attribute 'getOrganizationWirelessDevicesEthernetStatuses' HOT 1
- Async operations gets a certificate error (while sync operation works fine) HOT 10
- Library crashes with AttributeError when API returns 404 with no body HOT 1
- meraki 1.39 shows support for python 3.7 HOT 1
- installation fails on Windows HOT 1
- batch.networks.removeNetworkDevices has the incorrect operation HOT 2
- passing pagination (total_pages) params to getOrganizationApplianceTrafficShapingVpnExclusionsByNetwork results in error HOT 4
- Minor Documentation Spelling Error HOT 2
- API Endpoint /organizations/{organizationId}/wireless/radio/autoRf/byNetwork Missing HOT 1
- Generator does not add the required query parameters to methods if the query parameters are arrays of objects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dashboard-api-python.