Skip to content

Calling list_files on an ImageKit object throws unexpected keyword "created_by" error #40

@seandevs

Description

@seandevs

Hi There,

When calling list_files on an ImageKit object, it throws a "created_by" error on any new image uploaded to ImageKit in the Media Library. This may have to do with a new attribute called "created" that is appearing in the web interface. To reproduce the error:

    imagekit_obj = ImageKit(
        private_key=IMAGEKIT_PRIVATE_KEY,
        public_key=IMAGEKIT_PUBLIC_KEY,
        url_endpoint=IMAGEKIT_URL_ENDPOINT,
    )

    options = ListAndSearchFileRequestOptions(
        type="file", sort="ASC_CREATED", file_type="all"
    )
    
    results = imagekit_obj.list_files(options=options)

This throws TypeError: FileResult.__init__() got an unexpected keyword argument 'created_by.

Seems to be related to utils/utils.py

def convert_to_list_response_object(
    resp: Response, response_object, list_response_object
):
    response_list = []
    for item in resp.json():
        res_new = loads(dumps(camel_dict_to_snake_dict(item)))
        u = response_object(**res_new)
        response_list.append(u)

    u = list_response_object(response_list)
    u.response_metadata = ResponseMetadata(resp.json(), resp.status_code, resp.headers)
    return u

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