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 Amazon Ads: added 404 handling for sponsored_product_ad_group_bid_recommendations… #29900

Merged
merged 2 commits into from Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -13,5 +13,5 @@ ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]


LABEL io.airbyte.version=3.1.0
LABEL io.airbyte.version=3.1.1
LABEL io.airbyte.name=airbyte/source-amazon-ads
Expand Up @@ -8,7 +8,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: c6b0a29e-1da9-4512-9002-7bfd0cba2246
dockerImageTag: 3.1.0
dockerImageTag: 3.1.1
dockerRepository: airbyte/source-amazon-ads
githubIssueLabel: source-amazon-ads
icon: amazonads.svg
Expand Down
Expand Up @@ -104,6 +104,13 @@ def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapp
f"Skip current AdGroup because it does not support request {response.request.url} for "
f"{response.request.headers['Amazon-Advertising-API-Scope']} profile: {response.text}"
)
elif response.status_code == HTTPStatus.NOT_FOUND:
# 404 Either the specified ad group identifier was not found,
# or the specified ad group was found but no associated bid was found.
self.logger.warning(
f"Skip current AdGroup because the specified ad group has no associated bid {response.request.url} for "
f"{response.request.headers['Amazon-Advertising-API-Scope']} profile: {response.text}"
)

else:
response.raise_for_status()
Expand Down
Expand Up @@ -72,8 +72,8 @@ def setup_responses(
)


def get_all_stream_records(stream):
records = stream.read_records(SyncMode.full_refresh)
def get_all_stream_records(stream, stream_slice=None):
records = stream.read_records(SyncMode.full_refresh, stream_slice=stream_slice)
return [r for r in records]


Expand Down Expand Up @@ -273,3 +273,20 @@ def test_streams_brands_and_products(config, stream_name, endpoint, profiles_res
records = get_all_stream_records(test_stream)
assert records == []
assert any([endpoint in call.request.url for call in responses.calls])


@responses.activate
def test_sponsored_product_ad_group_bid_recommendations_404_error(caplog, config, profiles_response):
setup_responses(profiles_response=profiles_response)
responses.add(
responses.GET,
"https://advertising-api.amazon.com/v2/sp/adGroups/xxx/bidRecommendations",
json={"code": "404", "details": "404 Either the specified ad group identifier was not found or the specified ad group was found but no associated bid was found."},
status=404,
)
source = SourceAmazonAds()
streams = source.streams(config)
test_stream = get_stream_by_name(streams, "sponsored_product_ad_group_bid_recommendations")
records = get_all_stream_records(test_stream, stream_slice={'profileId': '1231', 'adGroupId': 'xxx'})
assert records == []
assert "Skip current AdGroup because the specified ad group has no associated bid" in caplog.text
1 change: 1 addition & 0 deletions docs/integrations/sources/amazon-ads.md
Expand Up @@ -103,6 +103,7 @@ Information about expected report generation waiting time you may find [here](ht

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------|
| 3.1.1 | 2023-08-28 | [29900](https://github.com/airbytehq/airbyte/pull/29900) | Add 404 handling for no assotiated with bid ad groups |
| 3.1.0 | 2023-08-08 | [00000](https://github.com/airbytehq/airbyte/pull/00000) | Add `T00030` tactic support for `sponsored_display_report_stream` |
| 3.0.0 | 2023-07-24 | [27868](https://github.com/airbytehq/airbyte/pull/27868) | Fix attribution report stream schemas |
| 2.3.1 | 2023-07-11 | [28155](https://github.com/airbytehq/airbyte/pull/28155) | Bugfix: validation error when record values are missing |
Expand Down