facebook-python-business-sdk icon indicating copy to clipboard operation
facebook-python-business-sdk copied to clipboard

TypeError in ObjectParser

Open five-hundred-eleven opened this issue 10 years ago • 5 comments

After a certain call to AdAccount.get_insights() resulted in the following:

File "facebookads/api.py", line 663, in execute
  return self._response_parser.parse_single(response.json())
File "facebookads/adobjects/objectparser.py", line 64, in parse_single
  _, data = data['images'].popitem()
TypeError: string indices must be integers

It appears to be an isolated incident that I haven't been able to reproduce.

There have been other issues raised regarding data being an invalid type in this block. I'd suggest wrapping the entire thing in a check such as: if isinstance(data['results'], dict)

five-hundred-eleven avatar Sep 07 '16 18:09 five-hundred-eleven

Pull request at https://github.com/facebook/facebook-python-ads-sdk/pull/251

five-hundred-eleven avatar Sep 07 '16 18:09 five-hundred-eleven

I've also run into this bug.

karstendick avatar Sep 11 '17 21:09 karstendick

I'm not sure exactly whether it's the same bug but here's the traceback for reference:

TypeError: string indices must be integers
at _set_data (/env/local/lib/python2.7/site-packages/facebookads/adobjects/helpers/adimagemixin.py:91)
at create_object (/env/local/lib/python2.7/site-packages/facebookads/adobjects/abstractobject.py:167)
at parse_multiple (/env/local/lib/python2.7/site-packages/facebookads/adobjects/objectparser.py:96)
at build_objects_from_response (/env/local/lib/python2.7/site-packages/facebookads/api.py:822)
at load_next_page (/env/local/lib/python2.7/site-packages/facebookads/api.py:813)
at __next__ (/env/local/lib/python2.7/site-packages/facebookads/api.py:763)

suhaasprasad avatar Oct 27 '17 17:10 suhaasprasad

When this issue would be fixed? Also encountering the same problem.

ellayunyun avatar Jun 12 '18 09:06 ellayunyun

Hi, it seems like this issue has been open for quite a while now. We have made many changes in the SDK since then, including releasing a new version. If you can repro your specific issue with the latest version of the SDK, please create a new issue or comment here with further details.

codytwinton avatar Aug 27 '18 18:08 codytwinton