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 Stripe: fix taxes-related tables in CheckoutSessionsLineItems + delete redundant secret key validation #8182

Merged
merged 6 commits into from
Nov 24, 2021

Conversation

grkhr
Copy link
Contributor

@grkhr grkhr commented Nov 22, 2021

What

How

Added taxes param to stripe stream request. There were schema for this table but not in the request to Stripe.
Also, I've deleted regexp validation, causing bugs mentioned in Slack (e.g. it was unable to delete this source, there is some bug with validation itself). I've found this redundant because there is a clear example in doc and Stripe can change key-generating logic at any moment.

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.
root@airbyte-dev:/home/eduard/airbyte/airbyte-integrations/connectors/source-stripe# python3 -m pytest integration_tests --full-trace
======================================================================================== test session starts ========================================================================================
platform linux -- Python 3.7.3, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/eduard/airbyte, configfile: pytest.ini
collected 1 item

integration_tests/test_dummy.py::test_dummy PASSED

========================================================================================= 1 passed in 0.01s =========================================================================================
root@airbyte-dev:/home/eduard/airbyte/airbyte-integrations/connectors/source-stripe# python3 -m pytest unit_tests
======================================================================================== test session starts ========================================================================================
platform linux -- Python 3.7.3, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /home/eduard/airbyte, configfile: pytest.ini
collected 4 items

unit_tests/test_source.py::test_lookback_window[None-1637606827.766514-1637606827.766514-if lookback_window_days is not set should not affect cursor value] PASSED
unit_tests/test_source.py::test_lookback_window[0-1637606827.766514-1637606827.766514-if lookback_window_days is not set should not affect cursor value] PASSED
unit_tests/test_source.py::test_lookback_window[10-1637606827.766514-1636742827-Should calculate cursor value as expected] {"type": "LOG", "log": {"level": "INFO", "message": "Applying lookback window of 10 days to stream invoices"}}
PASSED
unit_tests/test_source.py::test_lookback_window[-10-1637606827.766514-1636742827-Should not care for the sign, use the module] {"type": "LOG", "log": {"level": "INFO", "message": "Applying lookback window of -10 days to stream invoices"}}
PASSED

========================================================================================= warnings summary ==========================================================================================
airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[None-1637606827.766514-1637606827.766514-if lookback_window_days is not set should not affect cursor value]
airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[0-1637606827.766514-1637606827.766514-if lookback_window_days is not set should not affect cursor value]
airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[10-1637606827.766514-1636742827-Should calculate cursor value as expected]
airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[-10-1637606827.766514-1636742827-Should not care for the sign, use the module]
  /usr/local/lib/python3.7/dist-packages/airbyte_cdk/sources/streams/http/http.py:37: DeprecationWarning: Call to deprecated class NoAuth. (Set `authenticator=None` instead) -- Deprecated since version 0.1.20.
    self._authenticator = NoAuth()

airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[None-1637606827.766514-1637606827.766514-if lookback_window_days is not set should not affect cursor value]
airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[0-1637606827.766514-1637606827.766514-if lookback_window_days is not set should not affect cursor value]
airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[10-1637606827.766514-1636742827-Should calculate cursor value as expected]
airbyte-integrations/connectors/source-stripe/unit_tests/test_source.py::test_lookback_window[-10-1637606827.766514-1636742827-Should not care for the sign, use the module]
  /usr/local/lib/python3.7/dist-packages/deprecated/classic.py:173: DeprecationWarning: Call to deprecated class HttpAuthenticator. (Use requests.auth.AuthBase instead) -- Deprecated since version 0.1.20.
    return old_new1(cls, *args, **kwargs)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=================================================================================== 4 passed, 8 warnings in 0.27s ===================================================================================

❗️Also I've build docker image and tested it by adding custom connector in UI. It can be found here and easily added to existing Airbyte instance.

Here is screenshot from database after testing
image

  • 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

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
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

@CLAassistant
Copy link

CLAassistant commented Nov 22, 2021

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the area/connectors Connector related issues label Nov 22, 2021
@grkhr grkhr marked this pull request as ready for review November 22, 2021 19:09
@github-actions github-actions bot added the area/documentation Improvements or additions to documentation label Nov 24, 2021
@grkhr grkhr marked this pull request as draft November 24, 2021 10:22
@grkhr grkhr marked this pull request as ready for review November 24, 2021 10:23
@github-actions github-actions bot removed the area/documentation Improvements or additions to documentation label Nov 24, 2021
@grkhr grkhr marked this pull request as draft November 24, 2021 11:44
@grkhr grkhr marked this pull request as ready for review November 24, 2021 12:51
@@ -377,7 +377,7 @@ def read_records(self, stream_slice: Optional[Mapping[str, Any]] = None, **kwarg

def request_params(self, stream_slice: Mapping[str, Any] = None, **kwargs):
params = super().request_params(stream_slice=stream_slice, **kwargs)
params["expand[]"] = "data.discounts"
params["expand[]"] = ["data.discounts", "data.taxes"]
Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't this change the output schema? if so, we should update the .json schema file for this stream in order for normalization to process it correctly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Schema was already in .json, you can check here, for some reason developer forgot to add this param. That's all.

@@ -9,7 +9,6 @@
"properties": {
"client_secret": {
"type": "string",
"pattern": "^(s|r)k_(live|test)_[a-zA-Z0-9]+$",
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the reason to remove this? it's better to give feedback instantly if we know it's correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've found that I'm unable to delete Stripe source in Airbyte UI (and I'm not alone). Also, I found this redundant because there is a clear example in the settings page of the connector for this key and Stripe can change key-generating logic at any moment.

Seems that the real reason for that bug is somewhere in backend logic which isn't related to stripe connector, so it's easier to delete excessive validation. Btw you can reproduce it — just add the latest stripe source, configure It, try to delete and open web inspector in your browser to see errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for the context. this seems like a fair workaround then. Ive created an issue to address the root cause: #8244

@sherifnada sherifnada mentioned this pull request Nov 24, 2021
@sherifnada sherifnada temporarily deployed to more-secrets November 24, 2021 17:47 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets November 24, 2021 17:48 Inactive
@jrhizor jrhizor temporarily deployed to more-secrets November 24, 2021 18:05 Inactive
@grkhr
Copy link
Contributor Author

grkhr commented Nov 24, 2021

Do I need to bump the version and changelog? I did it here but reverted because of confusion of a review process

@sherifnada sherifnada merged commit dae0d77 into airbytehq:master Nov 24, 2021
@sherifnada
Copy link
Contributor

nope, you're good to go. Thanks @grkhr !

sherifnada added a commit that referenced this pull request Nov 24, 2021
Co-authored-by: grkhr <[email protected]>
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 2022
schlattk pushed a commit to schlattk/airbyte that referenced this pull request Jan 4, 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 community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants