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 Shopify: fix 404 for configured streams, fix missing cursor error for old records #17777

Merged
merged 8 commits into from
Oct 12, 2022

Conversation

bazarnov
Copy link
Collaborator

@bazarnov bazarnov commented Oct 10, 2022

What

Resolving:

How

  • override should_retry logic to cover 404 status code for discovered streams, but still are not available for certain regions due to Shopify limitations.
  • updated filter_records_newer_that_state logic to cover missing cursor_field for very old records.
  • added correspond unit_test to cover the case.
  • removed oauth flow from connectors spec, leaving client_id client_secret in place for custom oauth usage. The primary option for authentication is API Password

🚨 User Impact 🚨

No impact is expected.

Pre-merge Checklist

Expand the relevant checklist and delete the others.

Updating a connector

Community member or Airbyter

  • 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
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

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
  • If new credentials are required for use in CI, add them to GSM. Instructions.
  • /test connector=connectors/<name> command is passing
  • New Connector version released on Dockerhub and connector version bumped by running the /publish command described here

@bazarnov

This comment was marked as outdated.

@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Oct 10, 2022
@bazarnov

This comment was marked as outdated.

@bazarnov bazarnov linked an issue Oct 10, 2022 that may be closed by this pull request
@bazarnov
Copy link
Collaborator Author

bazarnov commented Oct 10, 2022

/test connector=connectors/source-shopify

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

Name                          Stmts   Miss  Cover
-------------------------------------------------
source_shopify/__init__.py        2      0   100%
source_shopify/transform.py      58      3    95%
source_shopify/utils.py          58      6    90%
source_shopify/auth.py           20      4    80%
source_shopify/source.py        296    103    65%
-------------------------------------------------
TOTAL                           434    116    73%
	 Name                                                 Stmts   Miss  Cover   Missing
	 ----------------------------------------------------------------------------------
	 source_acceptance_test/base.py                          10      4    60%   15-18
	 source_acceptance_test/config.py                        83      6    93%   78-80, 84-86
	 source_acceptance_test/conftest.py                     164    164     0%   6-282
	 source_acceptance_test/plugin.py                        48     48     0%   6-104
	 source_acceptance_test/tests/test_core.py              329    111    66%   39, 50-58, 63-70, 74-75, 79-80, 164, 202-219, 228-236, 240-245, 251, 284-289, 327-334, 374-376, 379, 439-448, 477-478, 484, 487, 520-530, 543-568, 573-577
	 source_acceptance_test/tests/test_full_refresh.py       52      2    96%   34, 65
	 source_acceptance_test/tests/test_incremental.py       152     26    83%   21-23, 29-31, 36-43, 48-61, 239, 250-258
	 source_acceptance_test/utils/asserts.py                 37      2    95%   57-58
	 source_acceptance_test/utils/common.py                  77     17    78%   15-16, 24-30, 47-54, 64, 67
	 source_acceptance_test/utils/compare.py                 62     23    63%   21-51, 68, 97-99
	 source_acceptance_test/utils/connector_runner.py       112     50    55%   23-26, 32, 36, 39-67, 70-72, 75-77, 80-82, 85-87, 90-92, 95-113, 147-149
	 source_acceptance_test/utils/json_schema_helper.py     105     13    88%   30-31, 38, 41, 65-68, 96, 120, 190-192
	 ----------------------------------------------------------------------------------
	 TOTAL                                                 1358    466    66%

Build Passed

Test summary info:

All Passed

@bazarnov
Copy link
Collaborator Author

bazarnov commented Oct 12, 2022

/publish connector=connectors/source-shopify

🕑 Publishing the following connectors:
connectors/source-shopify
https://github.com/airbytehq/airbyte/actions/runs/3233942187


Connector Did it publish? Were definitions generated?
connectors/source-shopify

if you have connectors that successfully published but failed definition generation, follow step 4 here ▶️

@bazarnov bazarnov merged commit c04d317 into master Oct 12, 2022
@bazarnov bazarnov deleted the baz/15242-15386-fix-shopify branch October 12, 2022 12:16
@cgalliva
Copy link

I saw this got patched and updated the shopify connector, but I'm experiencing the same problem with the same record. It looks like it was only updated to handle the case where the cursor field isn't present, not when it's actually set to a null value (which is what's happening in my case:

This is the response from calling the price rule's discount code:

{
  "discount_codes": [
    {
      "id": 3...1,
      "price_rule_id": 6...9,
      "code": "B...H",
      "usage_count": 0,
      "created_at": null,
      "updated_at": null
    }
  ]
}

@bazarnov
Copy link
Collaborator Author

bazarnov commented Oct 14, 2022

I saw this got patched and updated the shopify connector, but I'm experiencing the same problem with the same record. It looks like it was only updated to handle the case where the cursor field isn't present, not when it's actually set to a null value (which is what's happening in my case:

This is the response from calling the price rule's discount code:

{
  "discount_codes": [
    {
      "id": 3...1,
      "price_rule_id": 6...9,
      "code": "B...H",
      "usage_count": 0,
      "created_at": null,
      "updated_at": null
    }
  ]
}

@cgalliva
What sync mode have you tried: full-refresh or incremental sync after the version update?

Please provide the logs, thank you.

The fix is pretty straight forward, but we need to be sure that comparison takes place with None >= str indeed, when cursor_field: null

@cgalliva
Copy link

cgalliva commented Oct 14, 2022

@cgalliva What sync mode have you tried: full-refresh or incremental sync after the version update?

Please provide the logs, thank you.

The fix is pretty straight forward, but we need to be sure that comparison takes place with None >= str indeed, when cursor_field: null

@bazarnov
The error happens on incremental sync on a new connection with just the price_rules and discount_codes streams. Here's the traceback from the logs, if you need the full log I can share it I'll have to go through and remove any info before I upload it.

2022-10-14 09:25:56 �[44msource�[0m > Reading discount_codes for price_rule_id: 615221231639
2022-10-14 09:25:57 �[44msource�[0m > Encountered an exception while reading stream discount_codes
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py", line 113, in read
    yield from self._read_stream(
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py", line 182, in _read_stream
    for record in record_iterator:
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py", line 244, in _read_incremental
    for record_counter, record_data in enumerate(records, start=1):
  File "/airbyte/integration_code/source_shopify/source.py", line 270, in read_records
    yield from self.filter_records_newer_than_state(stream_state=stream_state, records_slice=records)
  File "/airbyte/integration_code/source_shopify/source.py", line 141, in filter_records_newer_than_state
    if record.get(self.cursor_field, self.default_state_comparison_value) >= stream_state.get(self.cursor_field):
TypeError: '>=' not supported between instances of 'NoneType' and 'str'
2022-10-14 09:25:57 �[44msource�[0m > Finished syncing discount_codes
2022-10-14 09:25:57 �[44msource�[0m > SourceShopify runtimes:
Syncing stream discount_codes 5:08:16.282306
2022-10-14 09:25:57 �[44msource�[0m > '>=' not supported between instances of 'NoneType' and 'str'
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.9/site-packages/airbyte_cdk/entrypoint.py", line 123, in launch
    for message in source_entrypoint.run(parsed_args):
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/entrypoint.py", line 114, in run
    for message in generator:
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py", line 127, in read
    raise e
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py", line 113, in read
    yield from self._read_stream(
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py", line 182, in _read_stream
    for record in record_iterator:
  File "/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py", line 244, in _read_incremental
    for record_counter, record_data in enumerate(records, start=1):
  File "/airbyte/integration_code/source_shopify/source.py", line 270, in read_records
    yield from self.filter_records_newer_than_state(stream_state=stream_state, records_slice=records)
  File "/airbyte/integration_code/source_shopify/source.py", line 141, in filter_records_newer_than_state
    if record.get(self.cursor_field, self.default_state_comparison_value) >= stream_state.get(self.cursor_field):
TypeError: '>=' not supported between instances of 'NoneType' and 'str'

@bazarnov
Copy link
Collaborator Author

@cgalliva Thank you for sharing the traceback logs, we will prepare the fix asap.

jhammarstedt pushed a commit to jhammarstedt/airbyte that referenced this pull request Oct 31, 2022
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/shopify
Projects
None yet
6 participants