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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Source Zendesk Support: handle 429 response behavior when retrying #19967

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -270,7 +270,7 @@ def _retry(
if original_exception:
raise original_exception
raise DefaultBackoffException(request=request, response=response)
if response:
if response is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenoitHugonnard can you explain how this will solve the problem with 429? The change you made doesn't affect any logic.
if response is equal to if response is not None
If I'm not wrong :p

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is the key !

The issue we currently have, is when Zendesk responds with a 429 for organizations, the retry that can only happen if response is never called so Airbyte doesn't wait x seconds before retrying so Uncaught Error (see the associated issue).

The issue is that when we bool check the 429 response we get false but the content is not empty (we still get the headers having the info for the x-retry-after).

If we do this check you'll see :

for i in range(15):
    resp = requests.get(
        url="https://*****.zendesk.com/api/v2/organizations?start_time=946684800&page=1011",
        headers=headers,
        auth=auth
    )
    status_code = resp.status_code
    is_response = True if resp is not None else False
    print(status_code, is_response)

>>>200 True
200 True
200 True
200 True
200 True
200 True
200 True
200 True
200 True
200 True
429 True
429 True
429 True
429 True
429 True

Between this and the initial description of the PR, I only changed what I changed in the PR if response turns into if response is not None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the info @BenoitHugonnard

backoff_time = self.backoff_time(response)
time.sleep(max(0, int(backoff_time - response.elapsed.total_seconds())))
self.future_requests.append(
Expand Down