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

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

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1871,7 +1871,7 @@
- name: Zendesk Support
sourceDefinitionId: 79c1aa37-dae3-42ae-b333-d1c105477715
dockerRepository: airbyte/source-zendesk-support
dockerImageTag: 0.2.18
dockerImageTag: 0.2.19
documentationUrl: https://docs.airbyte.com/integrations/sources/zendesk-support
icon: zendesk.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16158,7 +16158,7 @@
path_in_connector_config:
- "credentials"
- "client_secret"
- dockerImage: "airbyte/source-zendesk-support:0.2.18"
- dockerImage: "airbyte/source-zendesk-support:0.2.19"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/zendesk-support"
connectionSpecification:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ COPY source_zendesk_support ./source_zendesk_support
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.2.18
LABEL io.airbyte.version=0.2.19
LABEL io.airbyte.name=airbyte/source-zendesk-support
Original file line number Diff line number Diff line change
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

@BenoitHugonnard BenoitHugonnard Dec 7, 2022

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
1 change: 1 addition & 0 deletions docs/integrations/sources/zendesk-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The Zendesk connector ideally should not run into Zendesk API limitations under

| Version | Date | Pull Request | Subject |
|:---------|:-----------| :------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `0.2.19` | 2022-12-09 | [19967](https://github.com/airbytehq/airbyte/pull/19967) | Fix reading response for more than 100k records |
| `0.2.18` | 2022-11-29 | [19432](https://github.com/airbytehq/airbyte/pull/19432) | Revert changes from version 0.2.15, use a test read instead |
| `0.2.17` | 2022-11-24 | [19792](https://github.com/airbytehq/airbyte/pull/19792) | Transform `ticket_comments.via` "-" to null |
| `0.2.16` | 2022-09-28 | [17326](https://github.com/airbytehq/airbyte/pull/17326) | Migrate to per-stream states. |
Expand Down