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 Amplitude: log error when got 404 #6541

Merged
merged 8 commits into from
Oct 12, 2021

Conversation

gaart
Copy link
Contributor

@gaart gaart commented Sep 29, 2021

What

Fix #6375 - add 404 error handler

How

Update the read_records method (Events stream), add a try / catch clause

Recommended reading order

  1. airbyte-integrations/connectors/source-amplitude/source_amplitude/api.py

Pre-merge Checklist

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 29, 2021

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added area/connectors Connector related issues area/documentation Improvements or additions to documentation labels Sep 29, 2021
@gaart gaart temporarily deployed to more-secrets September 29, 2021 13:53 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 1, 2021

/test connector=connectors/source-amplitude

🕑 connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1293986876
✅ connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1293986876
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              171     89    48%
	 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     109     11    90%
	 ------------------------------------------------------------------------
	 TOTAL                                                  825    411    50%
	 ---------- coverage: platform linux, python 3.8.10-final-0 -----------
	 Name                           Stmts   Miss  Cover
	 --------------------------------------------------
	 source_amplitude/__init__.py       2      0   100%
	 source_amplitude/api.py          126     42    67%
	 source_amplitude/source.py        24     12    50%
	 --------------------------------------------------
	 TOTAL                            152     54    64%

@jrhizor jrhizor temporarily deployed to more-secrets October 1, 2021 06:33 Inactive
# sometimes the API throws a 404 error for not obvious reasons, we have to handle it and log it.
try:
yield from super().read_records(sync_mode, cursor_field, stream_slice, stream_state)
except requests.exceptions.HTTPError as error:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think, it will handle all errors rather then only 404.



@patch.object(HttpStream, "read_records")
def raise_error():
Copy link
Contributor

Choose a reason for hiding this comment

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

What this for?

@gaart gaart temporarily deployed to more-secrets October 6, 2021 22:17 Inactive
…ude/api.py

Co-authored-by: Eugene Kulak <widowmakerreborn@gmail.com>
@gaart gaart temporarily deployed to more-secrets October 7, 2021 11:55 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 7, 2021

/test connector=connectors/source-amplitude

🕑 connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1317140249
❌ connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1317140249
🐛

@jrhizor jrhizor temporarily deployed to more-secrets October 7, 2021 16:57 Inactive
@davinchia
Copy link
Contributor

Please make sure the tests pass!

Co-authored-by: Davin Chia <davinchia@gmail.com>
@gaart gaart temporarily deployed to more-secrets October 12, 2021 06:48 Inactive
gaart and others added 3 commits October 12, 2021 09:56
# Conflicts:
#	docs/integrations/sources/amplitude.md
…ude/api.py

Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
@gaart
Copy link
Contributor Author

gaart commented Oct 12, 2021

/test connector=connectors/source-amplitude

🕑 connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1331972651
✅ connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1331972651
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_amplitude/__init__.py       2      0   100%
	 source_amplitude/api.py          128     42    67%
	 source_amplitude/source.py        24     12    50%
	 --------------------------------------------------
	 TOTAL                            154     54    65%

@gaart gaart temporarily deployed to more-secrets October 12, 2021 07:00 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets October 12, 2021 07:01 Inactive
@gaart
Copy link
Contributor Author

gaart commented Oct 12, 2021

/publish connector=connectors/source-amplitude

🕑 connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1332002561
✅ connectors/source-amplitude https://github.com/airbytehq/airbyte/actions/runs/1332002561

@jrhizor jrhizor temporarily deployed to more-secrets October 12, 2021 07:10 Inactive
@gaart gaart merged commit 24c53b2 into master Oct 12, 2021
@gaart gaart deleted the gaart/6375-source-amplitude-sync-error branch October 12, 2021 07:24
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
* Add test

* Upd error handling

* Update airbyte-integrations/connectors/source-amplitude/source_amplitude/api.py

Co-authored-by: Eugene Kulak <widowmakerreborn@gmail.com>

* Update docs/integrations/sources/amplitude.md

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

* Update airbyte-integrations/connectors/source-amplitude/source_amplitude/api.py

Co-authored-by: Sherif A. Nada <snadalive@gmail.com>

Co-authored-by: Eugene Kulak <widowmakerreborn@gmail.com>
Co-authored-by: Davin Chia <davinchia@gmail.com>
Co-authored-by: Sherif A. Nada <snadalive@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 connectors/source/amplitude connectors/sources-api
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source Amplitude: connector throws 404 when dont have any data
8 participants