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 Google Ads: Better error message handling in check connection #11371

Merged
merged 5 commits into from
Mar 25, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
- name: Google Ads
sourceDefinitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
dockerRepository: airbyte/source-google-ads
dockerImageTag: 0.1.31
dockerImageTag: 0.1.32
documentationUrl: https://docs.airbyte.io/integrations/sources/google-ads
icon: google-adwords.svg
sourceType: api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-google-ads:0.1.31"
- dockerImage: "airbyte/source-google-ads:0.1.32"
spec:
documentationUrl: "https://docs.airbyte.com/integrations/sources/google-ads"
connectionSpecification:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ RUN pip install .

ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.31
LABEL io.airbyte.version=0.1.32
LABEL io.airbyte.name=airbyte/source-google-ads
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#


import traceback
from typing import Any, List, Mapping, Tuple, Union

from airbyte_cdk import AirbyteLogger
Expand Down Expand Up @@ -96,16 +97,18 @@ def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) ->
query = query.get("query")

if is_manager_account and self.is_metrics_in_custom_query(query):
raise Exception(f"Metrics are not available for manager account. Check fields in your custom query: {query}")
return False, f"Metrics are not available for manager account. Check fields in your custom query: {query}"
if CustomQuery.cursor_field in query:
raise Exception(f"Custom query should not contain {CustomQuery.cursor_field}")
return False, f"Custom query should not contain {CustomQuery.cursor_field}"

req_q = CustomQuery.insert_segments_date_expr(query, "1980-01-01", "1980-01-01")
for customer_id in google_api.customer_ids:
google_api.send_request(req_q, customer_id=customer_id)
return True, None
except GoogleAdsException as error:
return False, f"Unable to connect to Google Ads API with the provided credentials - {repr(error.failure)}"
except GoogleAdsException as exception:
error_messages = ", ".join([error.message for error in exception.failure.errors])
logger.error(traceback.format_exc())
return False, f"Unable to connect to Google Ads API with the provided credentials - {error_messages}"

def streams(self, config: Mapping[str, Any]) -> List[Stream]:
google_api = GoogleAds(credentials=self.get_credentials(config), customer_id=config["customer_id"])
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/google-ads.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ This source is constrained by whatever API limits are set for the Google Ads tha

| Version | Date | Pull Request | Subject |
|:---------|:-----------| :--- |:---------------------------------------------------------------------------------------------|
| `0.1.32` | 2022-03-24 | [11371](https://github.com/airbytehq/airbyte/pull/11371) | Improve how connection check returns error messages |
| `0.1.31` | 2022-03-23 | [11301](https://github.com/airbytehq/airbyte/pull/11301) | Update docs and spec to clarify usage |
| `0.1.30` | 2022-03-23 | [11221](https://github.com/airbytehq/airbyte/pull/11221) | Add `*_labels` streams to fetch the label text rather than their IDs |
| `0.1.29` | 2022-03-22 | [10919](https://github.com/airbytehq/airbyte/pull/10919) | Fix user location report schema and add to acceptance tests |
Expand Down