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

typechecker.py does not handle <list<map<string, string>>> correctly. #659

Closed
joshuamc98 opened this issue Dec 7, 2023 · 1 comment
Closed

Comments

@joshuamc98
Copy link
Contributor

**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
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 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
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 106, in is_type
sub_type_value = sub_types[1]
IndexError: list index out of range

This issue is caused by the typechecker not correctly handling a list of dictionary objects in additional_image_cdn_urls under the 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:

#658

@joshuamc98 joshuamc98 changed the title typechecker.py does not handle <list<map correctly. typechecker.py does not handle <list<map<string, string>>> correctly. Dec 7, 2023
@stcheng
Copy link
Contributor

stcheng commented Jan 23, 2024

#658

@stcheng stcheng closed this as completed Jan 23, 2024
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