Source Facebook Marketing: Retry pattern not working for unknown errors #25383
Labels
area/connectors
Connector related issues
community
connectors/source/facebook-marketing
connectors/sources-api
releaseStage/ga
team/connectors-python
type/bug
Something isn't working
Environment
Current Behavior
The
reduce_request_record_limit
function that is in thestreams.common.py
package is not working as expected.When the connector requests too much data and the call failed, this function should divide the
limit
param by 2 and try again with the decreased parameter.The retry pattern has this condition in
common.py
:exc.api_error_message() == "Please reduce the amount of data you're asking for, then retry your request"
for dividing the limit by 2.However, sometimes the API call returns the following error :
"An unknown error occurred"
and I noticed that decreasing the limit also fixed the API error in that case. So I added the case in thereduce_request_record_limit
function :exc.api_error_message() == "Please reduce the amount of data you're asking for, then retry your request" or exc.api_error_message() == "An unknown error occurred"
But if I do that, the limit parameter gets decreased for all next API calls. And I want it to reset the limit to the default value (usually 100) whenever the API call worked and not stay at the value it was set during the retry process because the next calls will take far too long with too small size.
For some reason, the limit parameter is rightly reset in the condition
exc.api_error_message() == "Please reduce the amount of data you're asking for, then retry your request"
but not if in the condition
exc.api_error_message() == "An unknown error occurred"
Expected Behavior
The
reduce_request_record_limit
function should also decrease the limit for"An unknown error occurred"
errors and reset it to the default limit after we go out of the retry process.Logs
Steps to Reproduce
exc.api_error_message() == "An unknown error occurred"
condition in thereduce_request_record_limit
function or create a Test caseAre you willing to submit a PR?
I hardcoded the reset in the
load_next_page
function in thepatches.py
file :self.params["limit"] = 100
but it will not be accepted in a PR.
The text was updated successfully, but these errors were encountered: