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

Library crashes with AttributeError when API returns 404 with no body #229

Closed
ollipa opened this issue Oct 16, 2023 · 1 comment
Closed

Comments

@ollipa
Copy link

ollipa commented Oct 16, 2023

Describe how you confirmed the issue is with the library, and not with the API itself, or a server-side issue of some other kind.
Error originates from the library.

Python version installed
Python 3.10

Meraki library version installed
1.38.0

Have you reproduced the issue with the latest version of this library? And with the latest version of Python?
I can reproduce the error with the latest library version.

Describe the bug
When Dashboard API returns 404 status (or any other status) with no body, the library doesn't handle the response well and crashes with AttributeError: 'NoneType' object has no attribute 'keys'.

How can we replicate the problem you're reporting?
Call AsyncDashboardAPI.organizations.getOrganizationNetworks with a non-existing organization id.

Expected behavior
The library should return APIError but it crashes instead an returns AttributeError: 'NoneType' object has no attribute 'keys'.

Additional context
The problem seems to be here:

message = await response.json(content_type = None)
message_is_dict = True

Aiohttp response.json returns None if the response body is empty and then the library sets message_is_dict incorrectly to True.

TKIPisalegacycipher added a commit that referenced this issue Oct 16, 2023
Fix for #229. Thank you @ollipa for reporting this.
@TKIPisalegacycipher
Copy link
Collaborator

@ollipa thanks for reporting this. The fix is merged and will be included in a future release of the library. Feel free to rebase on this current main branch if you like.

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