Skip to content

Source Zendesk Support: Handle 403 Error #23035

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

Merged
merged 9 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -2045,6 +2045,10 @@
icon: zendesk-support.svg
sourceType: api
releaseStage: generally_available
allowedHosts:
hosts:
- "${subdomain}.zendesk.com"
- zendesk.com
- name: Zendesk Talk
sourceDefinitionId: c8630570-086d-4a40-99ae-ea5b18673071
dockerRepository: airbyte/source-zendesk-talk
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.21
LABEL io.airbyte.version=0.2.22
LABEL io.airbyte.name=airbyte/source-zendesk-support

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def send_future(self, request: requests.PreparedRequest, **kwargs) -> Future:


class BaseSourceZendeskSupportStream(HttpStream, ABC):
raise_on_http_errors = True

def __init__(self, subdomain: str, start_date: str, ignore_pagination: bool = False, **kwargs):
super().__init__(**kwargs)

Expand Down Expand Up @@ -186,6 +188,13 @@ def parse_response(self, response: requests.Response, stream_state: Mapping[str,
if not cursor_date or updated > cursor_date:
yield record

def should_retry(self, response: requests.Response) -> bool:
if response.status_code == 403:
self.logger.error(f"Skipping stream {self.name}: Check permissions, error message: {response.json().get('error')}.")
setattr(self, "raise_on_http_errors", False)
return False
return super().should_retry(response)


class SourceZendeskSupportStream(BaseSourceZendeskSupportStream):
"""Basic Zendesk class"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_check(response, check_passed):
[
({"ticket_forms": [{"id": 1, "updated_at": "2021-07-08T00:05:45Z"}]}, 200, 18, []),
({"error": "Not sufficient permissions"}, 403, 17, [
"An exception occurred while trying to access TicketForms stream: 403 Client"
"Skipping stream ticket_forms: Check permissions, error message: Not sufficient permissions."
]),
],
ids=["forms_accessible", "forms_inaccessible"],
Expand All @@ -144,7 +144,7 @@ def test_full_access_streams(caplog, requests_mock, ticket_forms_response, statu
requests_mock.get("/api/v2/ticket_forms", status_code=status_code, json=ticket_forms_response)
result = SourceZendeskSupport().streams(config=TEST_CONFIG)
assert len(result) == expected_n_streams
logged_warnings = iter([record for record in caplog.records if record.levelname == "WARNING"])
logged_warnings = iter([record for record in caplog.records if record.levelname == "ERROR"])
for msg in expected_warnings:
assert msg in next(logged_warnings).message

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.21` | 2023-01-27 | [22027](https://github.com/airbytehq/airbyte/pull/22027) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| `0.2.22` | 2023-02-15 | [23035](https://github.com/airbytehq/airbyte/pull/23035) | Handle 403 Error |
| `0.2.21` | 2023-01-27 | [22027](https://github.com/airbytehq/airbyte/pull/22027) | Set `AvailabilityStrategy` for streams explicitly to `None` |
| `0.2.20` | 2022-12-28 | [20900](https://github.com/airbytehq/airbyte/pull/20900) | Remove synchronous time.sleep, add logging, reduce backoff time |
| `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 |
Expand Down