Skip to content

Commit

Permalink
🐛 Source Zendesk Support: fixed "Retry-After" non integer value (airb…
Browse files Browse the repository at this point in the history
…ytehq#14112)

Signed-off-by: Sergey Chvalyuk <[email protected]>
  • Loading branch information
grubberr authored Jun 27, 2022
1 parent 26a35af commit 76e50fd
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@
- name: Zendesk Support
sourceDefinitionId: 79c1aa37-dae3-42ae-b333-d1c105477715
dockerRepository: airbyte/source-zendesk-support
dockerImageTag: 0.2.10
dockerImageTag: 0.2.11
documentationUrl: https://docs.airbyte.io/integrations/sources/zendesk-support
icon: zendesk.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9853,7 +9853,7 @@
path_in_connector_config:
- "credentials"
- "client_secret"
- dockerImage: "airbyte/source-zendesk-support:0.2.10"
- dockerImage: "airbyte/source-zendesk-support:0.2.11"
spec:
documentationUrl: "https://docs.airbyte.io/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.10
LABEL io.airbyte.version=0.2.11
LABEL io.airbyte.name=airbyte/source-zendesk-support
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

import calendar
import re
import time
from abc import ABC
from collections import deque
Expand Down Expand Up @@ -31,6 +32,15 @@
END_OF_STREAM_KEY: str = "end_of_stream"


def to_int(s):
"https://github.com/airbytehq/airbyte/issues/13673"
if isinstance(s, str):
res = re.findall(r"[-+]?\d+", s)
if res:
return res[0]
return s


class SourceZendeskException(Exception):
"""default exception of custom SourceZendesk logic"""

Expand Down Expand Up @@ -78,7 +88,7 @@ def backoff_time(self, response: requests.Response) -> Union[int, float]:
The response has a Retry-After header that tells you for how many seconds to wait before retrying.
"""

retry_after = int(response.headers.get("Retry-After", 0))
retry_after = int(to_int(response.headers.get("Retry-After", 0)))
if retry_after > 0:
return retry_after

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def prepare_config(config: Dict):
return SourceZendeskSupport().convert_config2stream_args(config)


def test_backoff(requests_mock, config):
@pytest.mark.parametrize("retry_after, expected", [("5", 5), ("5, 4", 5)])
def test_backoff(requests_mock, config, retry_after, expected):
""" """
test_response_header = {"Retry-After": "5", "X-Rate-Limit": "0"}
test_response_header = {"Retry-After": retry_after, "X-Rate-Limit": "0"}
test_response_json = {"count": {"value": 1, "refreshed_at": "2022-03-29T10:10:51+00:00"}}
expected = int(test_response_header.get("Retry-After"))

# create client
config = prepare_config(config)
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/zendesk-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ The Zendesk connector ideally should not run into Zendesk API limitations under

| Version | Date | Pull Request | Subject |
|:---------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `0.2.10` | 2022-06-14 | [13757](https://github.com/airbytehq/airbyte/pull/13757) | Fixed the bug with `TicketMetrics` stream, HTTP Error 429, caused by lots of API requests |
| `0.2.11` | 2022-06-24 | [14112](https://github.com/airbytehq/airbyte/pull/14112) | Fixed "Retry-After" non integer value |
| `0.2.10` | 2022-06-14 | [13757](https://github.com/airbytehq/airbyte/pull/13757) | Fixed the bug with `TicketMetrics` stream, HTTP Error 429, caused by lots of API requests |
| `0.2.9` | 2022-05-27 | [13261](https://github.com/airbytehq/airbyte/pull/13261) | Bugfix for the unhandled [ChunkedEncodingError](https://github.com/airbytehq/airbyte/issues/12591) and [ConnectionError](https://github.com/airbytehq/airbyte/issues/12155) |
| `0.2.8` | 2022-05-20 | [13055](https://github.com/airbytehq/airbyte/pull/13055) | Fixed minor issue for stream `ticket_audits` schema |
| `0.2.7` | 2022-04-27 | [12335](https://github.com/airbytehq/airbyte/pull/12335) | Adding fixtures to mock time.sleep for connectors that explicitly sleep |
Expand Down

0 comments on commit 76e50fd

Please sign in to comment.