facebook / facebook-python-business-sdk

Python SDK for Meta Marketing APIs
https://developers.facebook.com/docs/business-sdk
Other
1.28k stars 631 forks source link

bugfix: get blame_field_specs from jsonified error_data object #563

Closed crazyministr closed 4 years ago

crazyministr commented 4 years ago

Initially, self._error['error_data'] contains blame_field_specs field as str. We are jsonifying self._error['error_data'] but getting blame_field_specs from initial object. So the fixed row getting exception:

Traceback (most recent call last):
 ...
  File "~/work/fanerd/venv_new_38/lib/python3.8/site-packages/facebook_business/api.py", line 125, in error
    return FacebookRequestError(
  File "~/work/fanerd/venv/lib/python3.8/site-packages/facebook_business/exceptions.py", line 85, in __init__
    self._error['error_data']['blame_field_specs']
TypeError: string indices must be integers

Here is body response:

{
'message': 'Invalid parameter', 
'type': 'OAuthException', 
'code': 100, 
'error_data': '{"blame_field_specs":[["time_stop"]]}', 
'error_subcode': 1487094, 
'is_transient': False, 
'error_user_title': 
'No end date entered', 
'error_user_msg': 'Ad sets using lifetime as the budget type must have an end date. Enter an end date more than 24 hours after the start time.', 
'fbtrace_id': 'AJu7yY4Mxbu0hpRv3hgvdwF'
}
facebook-github-bot commented 4 years ago

@jingping2015 merged this pull request in facebook/facebook-python-business-sdk@d9907883b0cfb8475f3147bf175c3be7a0cdf494.