Skip to content

Commit

Permalink
🐛Source Airtable: wrap HTTPError 400 in AirbyteTracedException (airby…
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton Karpets authored and ariesgun committed Oct 20, 2023
1 parent cc26174 commit 5551935
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 47 deletions.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-airtable/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_airtable ./source_airtable
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=4.1.0
LABEL io.airbyte.version=4.1.1
LABEL io.airbyte.name=airbyte/source-airtable
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,30 @@ acceptance_tests:
extra_fields: true
exact_order: true
extra_records: false
ignored_fields:
users/field_type_test/tblFcp5mncufoYaR9:
- name: "attachment"
bypass_reason: "Attachments' preview links are changed frequently"
"users/50_columns/tbl01Hi93Tt6XJ0u5":
- name: "attachments"
bypass_reason: "Attachments' preview links are changed frequently"
- name: "attachments_2"
bypass_reason: "Attachments' preview links are changed frequently"
- config_path: "secrets/config_oauth.json"
expect_records:
path: "integration_tests/expected_records.jsonl"
extra_fields: true
exact_order: true
extra_records: false
ignored_fields:
users/field_type_test/tblFcp5mncufoYaR9:
- name: "attachment"
bypass_reason: "Attachments' preview links are changed frequently"
"users/50_columns/tbl01Hi93Tt6XJ0u5":
- name: "attachments"
bypass_reason: "Attachments' preview links are changed frequently"
- name: "attachments_2"
bypass_reason: "Attachments' preview links are changed frequently"
full_refresh:
tests:
- config_path: "secrets/config.json"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 14c6e7ea-97ed-4f5e-a7b5-25e9a80b8212
dockerImageTag: 4.1.0
dockerImageTag: 4.1.1
dockerRepository: airbyte/source-airtable
githubIssueLabel: source-airtable
icon: airtable.svg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from typing import Any, Mapping, Union

import requests
from airbyte_cdk.models import FailureType
from airbyte_cdk.sources.streams.http.requests_native_auth import (
BasicHttpAuthenticator,
SingleUseRefreshTokenOauth2Authenticator,
TokenAuthenticator,
)
from airbyte_cdk.utils import AirbyteTracedException


class AirtableOAuth(SingleUseRefreshTokenOauth2Authenticator):
Expand Down Expand Up @@ -42,8 +44,15 @@ def _get_refresh_access_token_response(self) -> Mapping[str, Any]:
data=self.build_refresh_request_body(),
headers=self.build_refresh_request_headers(),
)
content = response.json()
if response.status_code == 400 and content.get("error") == "invalid_grant":
raise AirbyteTracedException(
internal_message=content.get("error_description"),
message="Refresh token is invalid or expired. Please re-authenticate to restore access to Airtable.",
failure_type=FailureType.config_error,
)
response.raise_for_status()
return response.json()
return content


class AirtableAuth:
Expand Down
3 changes: 2 additions & 1 deletion docs/integrations/sources/airtable.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ See information about rate limits [here](https://airtable.com/developers/web/api

| Version | Date | Pull Request | Subject |
|:--------|:-----------|:---------------------------------------------------------|:---------------------------------------------------------------------------------------|
| 4.1.0 | 2023-10-10 | [31044](https://github.com/airbytehq/airbyte/pull/31044) | Add source table name to output records |
| 4.1.1 | 2023-10-10 | [31119](https://github.com/airbytehq/airbyte/pull/31119) | Add user-friendly error message when refresh token has expired |
| 4.1.0 | 2023-10-10 | [31044](https://github.com/airbytehq/airbyte/pull/31044) | Add source table name to output records |
| 4.0.0 | 2023-10-09 | [31181](https://github.com/airbytehq/airbyte/pull/31181) | Additional schema processing for the FORMULA schema type: Convert to simple data types |
| 3.0.1 | 2023-05-10 | [25946](https://github.com/airbytehq/airbyte/pull/25946) | Skip stream if it does not appear in catalog |
| 3.0.0 | 2023-03-20 | [22704](https://github.com/airbytehq/airbyte/pull/22704) | Fix for stream name uniqueness |
Expand Down

0 comments on commit 5551935

Please sign in to comment.