Skip to content

Commit aa9b4ee

Browse files
Source Google Ads: handle authorization error (#27608)
* Source Google Ads: Fix pattern descriptor * 🤖 Auto format source-google-ads code [skip ci] * Source Google Ads: handle authorization error * Source Google Ads: handle authorization error --------- Co-authored-by: octavia-squidington-iii <octavia-squidington-iii@users.noreply.github.com>
1 parent d548587 commit aa9b4ee

File tree

9 files changed

+20
-3
lines changed

9 files changed

+20
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ COPY main.py ./
1313

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

16-
LABEL io.airbyte.version=0.2.23
16+
LABEL io.airbyte.version=0.2.24
1717
LABEL io.airbyte.name=airbyte/source-google-ads
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#

airbyte-integrations/connectors/source-google-ads/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ data:
66
connectorSubtype: api
77
connectorType: source
88
definitionId: 253487c0-2246-43ba-a21f-5116b20a2c50
9-
dockerImageTag: 0.2.23
9+
dockerImageTag: 0.2.24
1010
dockerRepository: airbyte/source-google-ads
1111
githubIssueLabel: source-google-ads
1212
icon: google-adwords.svg

airbyte-integrations/connectors/source-google-ads/source_google_ads/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#
14
"""
25
MIT License
36

airbyte-integrations/connectors/source-google-ads/source_google_ads/source.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from airbyte_cdk.sources.streams import Stream
1313
from airbyte_cdk.utils import AirbyteTracedException
1414
from google.ads.googleads.errors import GoogleAdsException
15+
from google.ads.googleads.v13.errors.types.authorization_error import AuthorizationErrorEnum
1516
from pendulum import parse, today
1617

1718
from .custom_query_stream import CustomQuery, IncrementalCustomQuery
@@ -121,6 +122,11 @@ def check_connection(self, logger: logging.Logger, config: Mapping[str, Any]) ->
121122
pass
122123
return True, None
123124
except GoogleAdsException as exception:
125+
if AuthorizationErrorEnum.AuthorizationError.USER_PERMISSION_DENIED in (
126+
x.error_code.authorization_error for x in exception.failure.errors
127+
):
128+
message = f"Failed to access the customer '{exception.customer_id}'. Ensure the customer is linked to your manager account or check your permissions to access this customer account."
129+
raise AirbyteTracedException(message=message, failure_type=FailureType.config_error)
124130
error_messages = ", ".join([error.message for error in exception.failure.errors])
125131
logger.error(traceback.format_exc())
126132
return False, f"Unable to connect to Google Ads API with the provided configuration - {error_messages}"

airbyte-integrations/connectors/source-google-ads/source_google_ads/spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"type": "string",
6161
"description": "Comma separated list of (client) customer IDs. Each customer ID must be specified as a 10-digit number without dashes. More instruction on how to find this value in our <a href=\"https://docs.airbyte.com/integrations/sources/google-ads#setup-guide\">docs</a>. Metrics streams like AdGroupAdReport cannot be requested for a manager account.",
6262
"pattern": "^[0-9]{10}(,[0-9]{10})*$",
63-
"pattern_descriptor": "^[0-9]{10}(,[0-9]{10})*$ . The customer ID must be 10 digits. Separate multiple customer IDs using commas.",
63+
"pattern_descriptor": "The customer ID must be 10 digits. Separate multiple customer IDs using commas.",
6464
"examples": ["6783948572,5839201945"],
6565
"order": 1
6666
},

airbyte-integrations/connectors/source-google-ads/source_google_ads/streams.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def read_records(self, sync_mode, stream_slice: Optional[Mapping[str, Any]] = No
136136
for response in response_records:
137137
yield from self.parse_response(response)
138138
except GoogleAdsException as exc:
139+
exc.customer_id = customer_id
139140
if not self.CATCH_API_ERRORS:
140141
raise
141142
for error in exc.failure.errors:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#
2+
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
3+
#

docs/integrations/sources/google-ads.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ Due to a limitation in the Google Ads API which does not allow getting performan
152152

153153
| Version | Date | Pull Request | Subject |
154154
|:---------|:-----------|:---------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------|
155+
| `0.2.24` | 2023-06-06 | [27608](https://github.com/airbytehq/airbyte/pull/27608) | Improve Google Ads exception handling |
155156
| `0.2.23` | 2023-06-06 | [26905](https://github.com/airbytehq/airbyte/pull/26905) | Replace deprecated `authSpecification` in the connector specification with `advancedAuth` |
156157
| `0.2.22` | 2023-06-02 | [26948](https://github.com/airbytehq/airbyte/pull/26948) | Refactor error messages; add `pattern_descriptor` for fields in spec |
157158
| `0.2.21` | 2023-05-30 | [25314](https://github.com/airbytehq/airbyte/pull/25314) | add full refresh custom table `asset_group_listing_group_filter` |

0 commit comments

Comments
 (0)