Skip to content

Commit e51853e

Browse files
grubberralafanechereoctavia-squidington-iiisupertopher
authored
Source Amazon Ads: fix bug with handling: "Report date is too far in the past." (partial revert of #20662) (#21082)
* Revert "Source Amazon Ads: fix bug with handling: "Report date is too far in the past." (#20662)" This reverts commit ec99595. * fix Signed-off-by: Sergey Chvalyuk <[email protected]> * revert master Signed-off-by: Sergey Chvalyuk <[email protected]> * revert to master Signed-off-by: Sergey Chvalyuk <[email protected]> * bump 0.1.27 Signed-off-by: Sergey Chvalyuk <[email protected]> * fix Signed-off-by: Sergey Chvalyuk <[email protected]> * amazon-ads.md updated Signed-off-by: Sergey Chvalyuk <[email protected]> * amazon-ads.md updated Signed-off-by: Sergey Chvalyuk <[email protected]> * auto-bump connector version Signed-off-by: Sergey Chvalyuk <[email protected]> Co-authored-by: Augustin <[email protected]> Co-authored-by: Octavia Squidington III <[email protected]> Co-authored-by: Topher Lubaway <[email protected]>
1 parent f2d1b2f commit e51853e

File tree

6 files changed

+7
-24
lines changed

6 files changed

+7
-24
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
- name: Amazon Ads
5555
sourceDefinitionId: c6b0a29e-1da9-4512-9002-7bfd0cba2246
5656
dockerRepository: airbyte/source-amazon-ads
57-
dockerImageTag: 0.1.26
57+
dockerImageTag: 0.1.27
5858
documentationUrl: https://docs.airbyte.com/integrations/sources/amazon-ads
5959
icon: amazonads.svg
6060
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,7 @@
719719
supportsNormalization: false
720720
supportsDBT: false
721721
supported_destination_sync_modes: []
722-
- dockerImage: "airbyte/source-amazon-ads:0.1.26"
722+
- dockerImage: "airbyte/source-amazon-ads:0.1.27"
723723
spec:
724724
documentationUrl: "https://docs.airbyte.com/integrations/sources/amazon-ads"
725725
connectionSpecification:

airbyte-integrations/connectors/source-amazon-ads/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

1515

16-
LABEL io.airbyte.version=0.1.26
16+
LABEL io.airbyte.version=0.1.27
1717
LABEL io.airbyte.name=airbyte/source-amazon-ads

airbyte-integrations/connectors/source-amazon-ads/source_amazon_ads/source.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,17 @@
3636
SponsoredProductsReportStream,
3737
SponsoredProductTargetings,
3838
)
39-
from .streams.report_streams.report_streams import ReportStream
4039

4140
# Oauth 2.0 authentication URL for amazon
4241
TOKEN_URL = "https://api.amazon.com/auth/o2/token"
4342
CONFIG_DATE_FORMAT = "YYYY-MM-DD"
4443

4544

4645
class SourceAmazonAds(AbstractSource):
47-
def _validate_and_transform(self, config: Mapping[str, Any], check=False):
46+
def _validate_and_transform(self, config: Mapping[str, Any]):
4847
start_date = config.get("start_date")
4948
if start_date:
5049
config["start_date"] = pendulum.from_format(start_date, CONFIG_DATE_FORMAT).date()
51-
if check:
52-
# This validation is used only for improving the user UX experience.
53-
# The connector can work without this low boundary checking.
54-
# We use REPORTING_PERIOD plus ONE additional day because
55-
# amazon account can have multiple profiles in different time zones.
56-
min_date = pendulum.today().date().subtract(days=ReportStream.REPORTING_PERIOD + 1)
57-
if config["start_date"] < min_date:
58-
raise Exception(f"Start Date: minimum allowed value is {min_date}")
5950
else:
6051
config["start_date"] = None
6152
if not config.get("region"):
@@ -70,7 +61,7 @@ def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) ->
7061
:return Tuple[bool, any]: (True, None) if the input config can be used to connect to the API successfully, (False, error) otherwise.
7162
"""
7263
try:
73-
config = self._validate_and_transform(config, check=True)
64+
config = self._validate_and_transform(config)
7465
except Exception as e:
7566
return False, str(e)
7667
# Check connection by sending list of profiles request. Its most simple

airbyte-integrations/connectors/source-amazon-ads/unit_tests/test_source.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
33
#
44

5-
import pendulum
65
import responses
76
from airbyte_cdk.models import AirbyteConnectionStatus, AirbyteMessage, ConnectorSpecification, Status, Type
8-
from freezegun import freeze_time
97
from jsonschema import Draft4Validator
108
from source_amazon_ads import SourceAmazonAds
119

@@ -43,7 +41,6 @@ def test_spec():
4341

4442

4543
@responses.activate
46-
@freeze_time("2022-12-20 10:00:00")
4744
def test_check(config_gen):
4845
setup_responses()
4946
source = SourceAmazonAds()
@@ -54,13 +51,7 @@ def test_check(config_gen):
5451
assert command_check(source, config_gen(start_date="")) == AirbyteConnectionStatus(status=Status.SUCCEEDED)
5552
assert len(responses.calls) == 4
5653

57-
assert source.check(None, config_gen(start_date="1900-01-01")) == AirbyteConnectionStatus(
58-
status=Status.FAILED, message="'Start Date: minimum allowed value is 2022-10-20'"
59-
)
60-
assert len(responses.calls) == 4
61-
62-
start_date = pendulum.today().format("YYYY-MM-DD")
63-
assert source.check(None, config_gen(start_date=start_date)) == AirbyteConnectionStatus(status=Status.SUCCEEDED)
54+
assert source.check(None, config_gen(start_date="2022-02-20")) == AirbyteConnectionStatus(status=Status.SUCCEEDED)
6455
assert len(responses.calls) == 6
6556

6657
assert command_check(source, config_gen(start_date="2022-20-02")) == AirbyteConnectionStatus(

docs/integrations/sources/amazon-ads.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Information about expected report generation waiting time you may find [here](ht
9494

9595
| Version | Date | Pull Request | Subject |
9696
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------|
97+
| 0.1.27 | 2023-01-05 | [21082](https://github.com/airbytehq/airbyte/pull/21082) | Fix bug with handling: "Report date is too far in the past." - partial revert of #20662 |
9798
| 0.1.26 | 2022-12-19 | [20662](https://github.com/airbytehq/airbyte/pull/20662) | Fix bug with handling: "Report date is too far in the past." |
9899
| 0.1.25 | 2022-11-08 | [18985](https://github.com/airbytehq/airbyte/pull/18985) | Remove "report_wait_timeout", "report_generation_max_retries" from config |
99100
| 0.1.24 | 2022-10-19 | [17475](https://github.com/airbytehq/airbyte/pull/17475) | Add filters for state on brand, product and display campaigns |

0 commit comments

Comments
 (0)