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 Hubspot: fix "quotes" key error exception #10055

Merged
merged 10 commits into from
Feb 10, 2022

Conversation

augan-rymkhan
Copy link
Contributor

@augan-rymkhan augan-rymkhan commented Feb 4, 2022

What

Resolves #9334
quotes stream will be added to the source connector only if credential type is API Key.
When OAUTH credentials are used and quotes stream is chosen, calling this method fails, which is called in _read_stream

2022-01-06 08:16:13 �[1;31mERROR�[m i.a.w.p.a.DefaultAirbyteStreamFactory(internalLog):95 - Encountered an exception while reading stream SourceHubspot
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/airbyte_cdk/sources/deprecated/base_source.py", line 67, in read
    yield from self._read_stream(logger=logger, client=client, configured_stream=configured_stream, state=total_state)
  File "/usr/local/lib/python3.7/site-packages/airbyte_cdk/sources/deprecated/base_source.py", line 79, in _read_stream
    use_incremental = configured_stream.sync_mode == SyncMode.incremental and client.stream_has_state(stream_name)
  File "/airbyte/integration_code/source_hubspot/client.py", line 76, in stream_has_state
    return hasattr(self._apis[name], "state")
KeyError: 'quotes'
2022-01-06 08:16:13 �[1;31mERROR�[m i.a.w.p.a.DefaultAirbyteStreamFactory(internalLog):95 - 'quotes'
Traceback (most recent call last):
  File "/airbyte/integration_code/main.py", line 13, in <module>
    launch(source, sys.argv[1:])
  File "/usr/local/lib/python3.7/site-packages/airbyte_cdk/entrypoint.py", line 116, in launch
    for message in source_entrypoint.run(parsed_args):
  File "/usr/local/lib/python3.7/site-packages/airbyte_cdk/entrypoint.py", line 107, in run
    for message in generator:
  File "/usr/local/lib/python3.7/site-packages/airbyte_cdk/sources/deprecated/base_source.py", line 67, in read
    yield from self._read_stream(logger=logger, client=client, configured_stream=configured_stream, state=total_state)
  File "/usr/local/lib/python3.7/site-packages/airbyte_cdk/sources/deprecated/base_source.py", line 79, in _read_stream
    use_incremental = configured_stream.sync_mode == SyncMode.incremental and client.stream_has_state(stream_name)
  File "/airbyte/integration_code/source_hubspot/client.py", line 76, in stream_has_state
    return hasattr(self._apis[name], "state")
KeyError: 'quotes'

How

Check whether quotes stream exists in the client, if no the connector should skip this stream by overriding method _read_stream in SourceHubspot.

Recommended reading order

  1. source_hubspot/source.py
  2. source-hubspot/unit_tests/test_client.py

@github-actions github-actions bot added the area/connectors Connector related issues label Feb 4, 2022
@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 4, 2022 09:57 Inactive
@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 4, 2022 12:11 Inactive
@augan-rymkhan
Copy link
Contributor Author

augan-rymkhan commented Feb 4, 2022

/test connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1794851312
❌ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1794851312
🐛 https://gradle.com/s/tsizt2qktbkzc

@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets February 4, 2022 12:17 Inactive
@augan-rymkhan augan-rymkhan changed the title Arymkhan/fix hubspot key error exception Source Hubspot: fix "quotes" key error exception Feb 4, 2022
@augan-rymkhan
Copy link
Contributor Author

augan-rymkhan commented Feb 7, 2022

/test connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1804565469
❌ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1804565469
🐛 https://gradle.com/s/i2gs3tubfln3i

@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets February 7, 2022 04:27 Inactive
@augan-rymkhan
Copy link
Contributor Author

augan-rymkhan commented Feb 7, 2022

/test connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1804959506
❌ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1804959506
🐛 https://gradle.com/s/cvjurqaxzktds

@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 7, 2022 06:42 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets February 7, 2022 06:44 Inactive
@augan-rymkhan
Copy link
Contributor Author

augan-rymkhan commented Feb 7, 2022

/test connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1805281075
❌ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1805281075
🐛 https://gradle.com/s/6gcbvcocyvs5e

@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 7, 2022 08:15 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets February 7, 2022 08:16 Inactive
@augan-rymkhan
Copy link
Contributor Author

augan-rymkhan commented Feb 7, 2022

/test connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1805510845
❌ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1805510845
🐛 https://gradle.com/s/5veapo6lfuovk

@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 7, 2022 09:09 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets February 7, 2022 09:11 Inactive
@augan-rymkhan
Copy link
Contributor Author

augan-rymkhan commented Feb 7, 2022

/test connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1805666658
✅ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1805666658
Python tests coverage:

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      6    92%
source_acceptance_test/tests/__init__.py                 4      0   100%
source_acceptance_test/tests/test_core.py              275    106    61%
source_acceptance_test/tests/test_full_refresh.py       52      2    96%
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                  70     17    76%
source_acceptance_test/utils/compare.py                 62     23    63%
source_acceptance_test/utils/connector_runner.py       110     48    56%
source_acceptance_test/utils/json_schema_helper.py     105     13    88%
------------------------------------------------------------------------
TOTAL                                                  876    259    70%
Name                         Stmts   Miss  Cover
------------------------------------------------
source_hubspot/__init__.py       2      0   100%
source_hubspot/api.py          555    132    76%
source_hubspot/client.py        40     12    70%
source_hubspot/errors.py         6      0   100%
source_hubspot/source.py        12      1    92%
------------------------------------------------
TOTAL                          615    145    76%

@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 7, 2022 09:43 Inactive
@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets February 7, 2022 09:44 Inactive
@augan-rymkhan augan-rymkhan marked this pull request as ready for review February 7, 2022 09:52
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Feb 10, 2022
@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 10, 2022 04:21 Inactive
@codecov
Copy link

codecov bot commented Feb 10, 2022

Codecov Report

❗ No coverage uploaded for pull request base (master@b447bb5). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head fcc8d02 differs from pull request most recent head b929cf0. Consider uploading reports for the commit b929cf0 to get more accurate results

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #10055   +/-   ##
=========================================
  Coverage          ?   76.39%           
=========================================
  Files             ?        5           
  Lines             ?      610           
  Branches          ?        0           
=========================================
  Hits              ?      466           
  Misses            ?      144           
  Partials          ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b447bb5...b929cf0. Read the comment docs.

@augan-rymkhan
Copy link
Contributor Author

augan-rymkhan commented Feb 10, 2022

/publish connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1821902006
✅ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/1821902006

@octavia-squidington-iii octavia-squidington-iii temporarily deployed to more-secrets February 10, 2022 04:26 Inactive
@augan-rymkhan augan-rymkhan merged commit b22efc0 into master Feb 10, 2022
@augan-rymkhan augan-rymkhan deleted the arymkhan/fix-hubspot-key-error-exception branch February 10, 2022 04:39
@augan-rymkhan augan-rymkhan temporarily deployed to more-secrets February 10, 2022 04:40 Inactive
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.

Encountered an exception while reading stream SourceHubspot
5 participants