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: fix 404 responses for the ticket_comments stream #6513

Merged
merged 15 commits into from
Oct 15, 2021

Conversation

antixar
Copy link
Contributor

@antixar antixar commented Sep 28, 2021

What

There is an issue with relevant statutes for a lot of tickets. Some of them can be deleted by users while comments loading.

How

Need to handle 404 code responses for same cases.

Recommended reading order

  1. streams.py

Pre-merge Checklist

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions
  • Connector version bumped like described here

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here

@CLAassistant
Copy link

CLAassistant commented Sep 28, 2021

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ antixar
❌ Maksym Pavlenok


Maksym Pavlenok seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added the area/connectors Connector related issues label Sep 28, 2021
@antixar antixar self-assigned this Sep 28, 2021
@antixar antixar temporarily deployed to more-secrets September 29, 2021 16:02 Inactive
@antixar antixar linked an issue Sep 29, 2021 that may be closed by this pull request
@antixar
Copy link
Contributor Author

antixar commented Sep 29, 2021

/test connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1288740849
❌ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1288740849
🐛 https://gradle.com/s/jvo5btsvjga64

@jrhizor jrhizor temporarily deployed to more-secrets September 29, 2021 22:11 Inactive
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Sep 30, 2021
@antixar antixar temporarily deployed to more-secrets September 30, 2021 22:07 Inactive
@antixar
Copy link
Contributor Author

antixar commented Sep 30, 2021

/test connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1292864618
✅ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1292864618
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              197     93    53%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     24    41%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     111     11    90%
	 ------------------------------------------------------------------------
	 TOTAL                                                  853    415    51%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      273     75    73%
	 --------------------------------------------------------
	 TOTAL                                  313     90    71%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      273    114    58%
	 --------------------------------------------------------
	 TOTAL                                  313    129    59%

@jrhizor jrhizor temporarily deployed to more-secrets September 30, 2021 22:09 Inactive
@antixar antixar requested a review from midavadim October 1, 2021 14:20
Copy link
Collaborator

@lazebnyi lazebnyi left a comment

Choose a reason for hiding this comment

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

LGTM

@antixar antixar requested a review from Phlair October 4, 2021 15:48
Copy link
Contributor

@Phlair Phlair left a comment

Choose a reason for hiding this comment

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

Awesome, adding a few useful things here. Could you update the title/description to reflect all that (since it's more than just fixing the 404 bug).

Just one main concern at the moment in my comments.

)

if ticket_pages:
last_times = sorted(ticket_pages.keys())
Copy link
Contributor

Choose a reason for hiding this comment

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

based on doing ticket_pages[tickets_stream.last_end_time].append(... above, won't ticket_pages just have one unique key which is Tickets(start_date=self._start_date, subdomain=self._subdomain, authenticator=self.authenticator).last_end_time?

This code seems like it expects multiple...

Copy link
Contributor

Choose a reason for hiding this comment

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

(relevant down to line 430)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not necessary, the option last_end_time is updated by every new request to the zendesk server. And there is an probability that a bit of tickets were updated simultaneously. For example: Some script added 3000 comments to 3000 tickets. All them would have same updated time. And as result this connector would load same last_end_time value for 3 different consistent reques. Thus this logic tries to aggregate all tickets with same last_end_time.
Sure, this probability is unlikely but I added the aggregation just in case

Copy link
Contributor

Choose a reason for hiding this comment

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

Understood, I was missing the knowledge that last_end_time gets updated on every request. It may already be commented somewhere but would be good to have comments in this logic as well to explain that.

…zendesk_support/streams.py

Co-authored-by: George Claireaux <george@claireaux.co.uk>
@antixar antixar temporarily deployed to more-secrets October 8, 2021 09:44 Inactive
@antixar antixar requested a review from Phlair October 8, 2021 11:28
Co-authored-by: Davin Chia <davinchia@gmail.com>
@antixar antixar temporarily deployed to more-secrets October 12, 2021 15:38 Inactive
…hub.com:airbytehq/airbyte into antixar/6249-zendesk-support-not-found-comments
@antixar
Copy link
Contributor Author

antixar commented Oct 13, 2021

/test connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1338482472
✅ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1338482472
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              200     94    53%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     24    41%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     115     14    88%
	 ------------------------------------------------------------------------
	 TOTAL                                                  860    419    51%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      275     78    72%
	 --------------------------------------------------------
	 TOTAL                                  315     93    70%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      275    114    59%
	 --------------------------------------------------------
	 TOTAL                                  315    129    59%

@antixar antixar temporarily deployed to more-secrets October 13, 2021 17:05 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets October 13, 2021 17:07 Inactive
Copy link
Contributor

@Phlair Phlair left a comment

Choose a reason for hiding this comment

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

Great lgtm, minor comments and code suggestions but all good to publish/merge when addressed 👍

Comment on lines 32 to 33
# from airbyte_cdk.sources.streams.http.auth.token import TokenAuthenticator

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# from airbyte_cdk.sources.streams.http.auth.token import TokenAuthenticator

)

if ticket_pages:
last_times = sorted(ticket_pages.keys())
Copy link
Contributor

Choose a reason for hiding this comment

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

Understood, I was missing the knowledge that last_end_time gets updated on every request. It may already be commented somewhere but would be good to have comments in this logic as well to explain that.

docs/integrations/sources/zendesk-support.md Outdated Show resolved Hide resolved
antixar and others added 2 commits October 15, 2021 20:04
Co-authored-by: George Claireaux <george@claireaux.co.uk>
…zendesk_support/streams.py

Co-authored-by: George Claireaux <george@claireaux.co.uk>
@antixar antixar temporarily deployed to more-secrets October 15, 2021 17:06 Inactive
@antixar
Copy link
Contributor Author

antixar commented Oct 15, 2021

/test connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1347563098
✅ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1347563098
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              200     94    53%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     24    41%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     115     14    88%
	 ------------------------------------------------------------------------
	 TOTAL                                                  860    419    51%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      275     78    72%
	 --------------------------------------------------------
	 TOTAL                                  315     93    70%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      275    114    59%
	 --------------------------------------------------------
	 TOTAL                                  315    129    59%

@antixar antixar temporarily deployed to more-secrets October 15, 2021 21:31 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets October 15, 2021 21:33 Inactive
@antixar antixar temporarily deployed to more-secrets October 15, 2021 21:39 Inactive
@antixar
Copy link
Contributor Author

antixar commented Oct 15, 2021

/test connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1347585203
✅ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1347585203
Python tests coverage:

	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                                 Stmts   Miss  Cover
	 ------------------------------------------------------------------------
	 source_acceptance_test/__init__.py                       2      0   100%
	 source_acceptance_test/base.py                          10      4    60%
	 source_acceptance_test/config.py                        74      8    89%
	 source_acceptance_test/conftest.py                     108    108     0%
	 source_acceptance_test/plugin.py                        47     47     0%
	 source_acceptance_test/tests/__init__.py                 4      0   100%
	 source_acceptance_test/tests/test_core.py              200     94    53%
	 source_acceptance_test/tests/test_full_refresh.py       18     11    39%
	 source_acceptance_test/tests/test_incremental.py        69     38    45%
	 source_acceptance_test/utils/__init__.py                 6      0   100%
	 source_acceptance_test/utils/asserts.py                 37      2    95%
	 source_acceptance_test/utils/common.py                  41     24    41%
	 source_acceptance_test/utils/compare.py                 47     20    57%
	 source_acceptance_test/utils/connector_runner.py        82     49    40%
	 source_acceptance_test/utils/json_schema_helper.py     115     14    88%
	 ------------------------------------------------------------------------
	 TOTAL                                                  860    419    51%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      275     78    72%
	 --------------------------------------------------------
	 TOTAL                                  315     93    70%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                                 Stmts   Miss  Cover
	 --------------------------------------------------------
	 source_zendesk_support/__init__.py       2      0   100%
	 source_zendesk_support/source.py        38     15    61%
	 source_zendesk_support/streams.py      275    114    59%
	 --------------------------------------------------------
	 TOTAL                                  315    129    59%

@jrhizor jrhizor temporarily deployed to more-secrets October 15, 2021 21:41 Inactive
@antixar
Copy link
Contributor Author

antixar commented Oct 15, 2021

/publish connector=connectors/source-zendesk-support

🕑 connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1347619283
✅ connectors/source-zendesk-support https://github.com/airbytehq/airbyte/actions/runs/1347619283

@jrhizor jrhizor temporarily deployed to more-secrets October 15, 2021 21:57 Inactive
@antixar antixar merged commit 592f7fe into master Oct 15, 2021
@antixar antixar deleted the antixar/6249-zendesk-support-not-found-comments branch October 15, 2021 22:20
@@ -23,6 +23,17 @@
"default": "api_token",
"description": "Zendesk service provides 2 auth method: API token and oAuth2. Now only the first one is available. Another one will be added in the future",
"oneOf": [
{
"type": "object",
"title": "OAuth2.0 authorization (not implemented)",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we adding this if it's not implemented? A user who sees this will lose confidence in the product

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was planned as temporary gap for the oauth future functionality. I remember to CI tests checked that oneOf items have to include more than 1 subitem. But now I see CI passes this test without problems.
You're right to it will be able to confuse users.
I've added a PR with correction.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah got it. thanks for making the change!

@sherifnada
Copy link
Contributor

@antixar is this PR also introducing oauth support? I am asking because the title doesn't reflect it, so we should either make sure to update the title appropriately

Also, please make sure to update the PR description in the future -- it's not clear to the reader what the root cause exactly is or how the PR solves it unless they read the whole PR which in this case is not trivial

@antixar
Copy link
Contributor Author

antixar commented Oct 16, 2021

@sherifnada , Initially this PR included correction for 2 critical bugs (they were fixed 2 weeks ago). Unfortunately oauth2 development is blocked. Thus I splitted all oauth2 logic to another PR. It will be bumped by separate version.

schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
…tream (airbytehq#6513)

* fix 404 responses for the ticket_comments stream

* add unit test

* add unit test

* add oauth2 access token

* Update airbyte-integrations/connectors/source-zendesk-support/source_zendesk_support/streams.py

Co-authored-by: George Claireaux <george@claireaux.co.uk>

* switching among auth methods

* Update docs/integrations/sources/zendesk-support.md

Co-authored-by: Davin Chia <davinchia@gmail.com>

* add log message for 404 errors

* Update docs/integrations/sources/zendesk-support.md

Co-authored-by: George Claireaux <george@claireaux.co.uk>

* Update airbyte-integrations/connectors/source-zendesk-support/source_zendesk_support/streams.py

Co-authored-by: George Claireaux <george@claireaux.co.uk>

* remove oauth logic from this PR

* remove oauth logic from this PR

Co-authored-by: Maksym Pavlenok <maksym.pavlenok@globallogic.com>
Co-authored-by: George Claireaux <george@claireaux.co.uk>
Co-authored-by: Davin Chia <davinchia@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues area/documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zendesk Source incremental sync is very slow Zendesk Support Still Failing - Error on comments.json
9 participants