Skip to content

AttributeError 'dict' object has no attribute 'extend' #306

@timoturkki

Description

@timoturkki

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.
The error is thrown from the library itself. Meraki API has returned 200. I do not have access to the actual response body for this case (does not happen for all cases), but the library should be able to handle this case and there seems to be a clear bug with the code.

Python version installed
3.12.7

Meraki library version installed
2.0.3

Have you reproduced the issue with the latest version of this library? And with the latest version of Python?
This error was reported to our monitoring tool from an end user using our application. I do not have API access to the organization in question and it does not seem to happen with any organization I have access to.

OS Platform
Linux

Describe the bug
The problematic code is in _get_pages_legacy -method

results.extend(json_response["items"])

The code in context:

elif isinstance(results, dict) and "items" in results:
                    json_response = await response.json(content_type=None)
                    results.extend(json_response["items"])

Looking at the code, it seems that first there is a check that results is a dict followed by trying to extend it. Since extend is available only for lists, an error is thrown. Perhaps the intention was to extend results["items"]?

How can we replicate the problem you're reporting?
Since this happened to our end customer (and reported to our monitoring tool), I do not have an API access to the case when this happened. I'm failing to replicate this error with the organizations I have access to. But looking at the code snippet above, the bug seems fairly obvious.

Edit: after some additional digging, this seems to happen with paginated responses when there are multiple pages

Expected behavior
The library should not throw an error but extend the results correctly.

Code snippets
Added in the description

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions