facebook-python-business-sdk
facebook-python-business-sdk copied to clipboard
typechecker.py does not handle <list<map<string, string>>> correctly.
**I tried to use the bug reporting channel for this bug but as it is not ad account related but catalog product related it does not seem I can report through the requested channels so am reporting here:
The stacktrace is as follows:**
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/adobjects/productcatalog.py", line 1686, in get_products
return request.execute()
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/api.py", line 663, in execute
cursor.load_next_page()
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/api.py", line 855, in load_next_page
self._queue = self.build_objects_from_response(response)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/api.py", line 864, in build_objects_from_response
return self._object_parser.parse_multiple(response)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/adobjects/objectparser.py", line 76, in parse_multiple
ret.append(self.parse_single(json_obj))
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/adobjects/objectparser.py", line 64, in parse_single
return AbstractObject.create_object(self._api, data,
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/adobjects/abstractobject.py", line 159, in create_object
new_object._set_data(data)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/adobjects/abstractcrudobject.py", line 178, in _set_data
self[key] = data[key]
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/adobjects/abstractcrudobject.py", line 56, in setitem
super(AbstractCrudObject, self).setitem(key, value)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/adobjects/abstractobject.py", line 46, in setitem
self._data[key] = self._field_checker.get_typed_value(key, value)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/typechecker.py", line 147, in get_typed_value
if self.is_type(field_type, value, allow_dict_as_obj=False):
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/typechecker.py", line 100, in is_type
return all(self.is_type(sub_type, item) for item in value)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/facebook_business/typechecker.py", line 100, in
This issue is caused by the typechecker not correctly handling a list of dictionary objects in additional_image_cdn_urls under the <ProductItem> object.
I've linked a pull request for this issue which fixes the logic in the is_type using similar logic I found in the is_typed_value method. Ideally this would be captured by one method but for simplicity I left it as a small change in the PR.
The main issue comes about due to trying to handle <list<map<string, string>>> where the , string> part gets split off incorrectly causing the list index out of range error.
The PR is here:
https://github.com/facebook/facebook-python-business-sdk/pull/658