From 090ef75c94f20e54730e8038d302649764f401ce Mon Sep 17 00:00:00 2001 From: Daryna Ishchenko <80129833+darynaishchenko@users.noreply.github.com> Date: Mon, 20 Mar 2023 17:19:36 +0200 Subject: [PATCH] Source Instagram: decrease give up rate (#23671) * updated spec and added more specific error message * added change log * refactored error handling * auto-bump connector version --------- Co-authored-by: Octavia Squidington III --- .../src/main/resources/seed/source_definitions.yaml | 2 +- .../init/src/main/resources/seed/source_specs.yaml | 9 +++++---- .../connectors/source-instagram/Dockerfile | 2 +- .../source-instagram/integration_tests/spec.json | 2 +- .../source-instagram/source_instagram/api.py | 10 ++++++++++ .../source-instagram/source_instagram/source.py | 8 +++++++- connectors.md | 2 +- docs/integrations/sources/instagram.md | 1 + 8 files changed, 27 insertions(+), 9 deletions(-) diff --git a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml index 32e645ca7ead6..6c1dcf9bd0bf3 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -938,7 +938,7 @@ - name: Instagram sourceDefinitionId: 6acf6b55-4f1e-4fca-944e-1a3caef8aba8 dockerRepository: airbyte/source-instagram - dockerImageTag: 1.0.3 + dockerImageTag: 1.0.4 documentationUrl: https://docs.airbyte.com/integrations/sources/instagram icon: instagram.svg sourceType: api diff --git a/airbyte-config/init/src/main/resources/seed/source_specs.yaml b/airbyte-config/init/src/main/resources/seed/source_specs.yaml index 66103557cbaf4..b3e9ad2bf83d0 100644 --- a/airbyte-config/init/src/main/resources/seed/source_specs.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_specs.yaml @@ -6959,7 +6959,7 @@ supportsNormalization: false supportsDBT: false supported_destination_sync_modes: [] -- dockerImage: "airbyte/source-instagram:1.0.3" +- dockerImage: "airbyte/source-instagram:1.0.4" spec: documentationUrl: "https://docs.airbyte.com/integrations/sources/instagram" changelogUrl: "https://docs.airbyte.com/integrations/sources/instagram" @@ -6979,9 +6979,10 @@ format: "date-time" access_token: title: "Access Token" - description: "The value of the access token generated. See the docs for\ - \ more information" + description: "The value of the access token generated with instagram_basic,\ + \ instagram_manage_insights, pages_show_list, pages_read_engagement, Instagram\ + \ Public Content Access permissions. See the docs for more information" airbyte_secret: true type: "string" required: diff --git a/airbyte-integrations/connectors/source-instagram/Dockerfile b/airbyte-integrations/connectors/source-instagram/Dockerfile index 8227656a5edeb..d5e0b46d2017d 100644 --- a/airbyte-integrations/connectors/source-instagram/Dockerfile +++ b/airbyte-integrations/connectors/source-instagram/Dockerfile @@ -12,5 +12,5 @@ RUN pip install . ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py" ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] -LABEL io.airbyte.version=1.0.3 +LABEL io.airbyte.version=1.0.4 LABEL io.airbyte.name=airbyte/source-instagram diff --git a/airbyte-integrations/connectors/source-instagram/integration_tests/spec.json b/airbyte-integrations/connectors/source-instagram/integration_tests/spec.json index 23f465b39df33..c4e2dbde50090 100644 --- a/airbyte-integrations/connectors/source-instagram/integration_tests/spec.json +++ b/airbyte-integrations/connectors/source-instagram/integration_tests/spec.json @@ -15,7 +15,7 @@ }, "access_token": { "title": "Access Token", - "description": "The value of the access token generated. See the docs for more information", + "description": "The value of the access token generated with instagram_basic, instagram_manage_insights, pages_show_list, pages_read_engagement, Instagram Public Content Access permissions. See the docs for more information", "airbyte_secret": true, "type": "string" } diff --git a/airbyte-integrations/connectors/source-instagram/source_instagram/api.py b/airbyte-integrations/connectors/source-instagram/source_instagram/api.py index 3f39ecf084299..428958fc0e3bf 100644 --- a/airbyte-integrations/connectors/source-instagram/source_instagram/api.py +++ b/airbyte-integrations/connectors/source-instagram/source_instagram/api.py @@ -88,6 +88,16 @@ def _find_accounts(self) -> List[Mapping[str, Any]]: } ) except FacebookRequestError as exc: + # 200 - 299, 3 and 10 are permission related error codes + if 200 <= exc.api_error_code() <= 299 or exc.api_error_code() in [3, 10]: + raise InstagramAPIException( + f"Error: {exc.api_error_code()}, {exc.api_error_message()}." + f"Also make sure that your Access Token has the following permissions: " + f"instagram_basic, instagram_manage_insights, pages_show_list, pages_read_engagement, and Instagram Public Content Access" + f"See error handling https://developers.facebook.com/docs/graph-api/guides/error-handling/ " + f"and permissions https://developers.facebook.com/docs/permissions/reference for more information." + ) from exc + raise InstagramAPIException(f"Error: {exc.api_error_code()}, {exc.api_error_message()}") from exc if not instagram_business_accounts: diff --git a/airbyte-integrations/connectors/source-instagram/source_instagram/source.py b/airbyte-integrations/connectors/source-instagram/source_instagram/source.py index b5d3d83d4be02..a0f00166fad5c 100644 --- a/airbyte-integrations/connectors/source-instagram/source_instagram/source.py +++ b/airbyte-integrations/connectors/source-instagram/source_instagram/source.py @@ -24,7 +24,13 @@ class Config: ) access_token: str = Field( - description='The value of the access token generated. See the docs for more information', + description=( + "The value of the access token generated with " + "instagram_basic, instagram_manage_insights, pages_show_list, pages_read_engagement, Instagram Public Content Access " + "permissions. " + 'See the docs for more ' + "information" + ), airbyte_secret=True, ) diff --git a/connectors.md b/connectors.md index fe3beee377c3a..ee00c71d871fc 100644 --- a/connectors.md +++ b/connectors.md @@ -107,7 +107,7 @@ | **IBM Db2** | IBM Db2 icon | Source | airbyte/source-db2:0.1.18 | alpha | [link](https://docs.airbyte.com/integrations/sources/db2) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-db2) | `447e0381-3780-4b46-bb62-00a4e3c8b8e2` | | **IP2Whois** | IP2Whois icon | Source | airbyte/source-ip2whois:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/ip2whois) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-ip2whois) | `f23b7b7c-d705-49a3-9042-09add3b104a5` | | **Insightly** | Insightly icon | Source | airbyte/source-insightly:0.1.1 | alpha | [link](https://docs.airbyte.com/integrations/sources/insightly) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-insightly) | `38f84314-fe6a-4257-97be-a8dcd942d693` | -| **Instagram** | Instagram icon | Source | airbyte/source-instagram:1.0.3 | generally_available | [link](https://docs.airbyte.com/integrations/sources/instagram) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-instagram) | `6acf6b55-4f1e-4fca-944e-1a3caef8aba8` | +| **Instagram** | Instagram icon | Source | airbyte/source-instagram:1.0.4 | generally_available | [link](https://docs.airbyte.com/integrations/sources/instagram) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-instagram) | `6acf6b55-4f1e-4fca-944e-1a3caef8aba8` | | **Instatus** | Instatus icon | Source | airbyte/source-instatus:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/instatus) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-instatus) | `1901024c-0249-45d0-bcac-31a954652927` | | **Intercom** | Intercom icon | Source | airbyte/source-intercom:0.1.32 | generally_available | [link](https://docs.airbyte.com/integrations/sources/intercom) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-intercom) | `d8313939-3782-41b0-be29-b3ca20d8dd3a` | | **Intruder** | Intruder icon | Source | airbyte/source-intruder:0.1.0 | alpha | [link](https://docs.airbyte.com/integrations/sources/intruder) | [code](https://github.com/airbytehq/airbyte/tree/master/airbyte-integrations/connectors/source-intruder) | `3d15163b-11d8-412f-b808-795c9b2c3a3a` | diff --git a/docs/integrations/sources/instagram.md b/docs/integrations/sources/instagram.md index be33cea5d5080..a1ce17fa2ecab 100644 --- a/docs/integrations/sources/instagram.md +++ b/docs/integrations/sources/instagram.md @@ -92,6 +92,7 @@ AirbyteRecords are required to conform to the [Airbyte type](https://docs.airbyt | Version | Date | Pull Request | Subject | |:--------|:-----------|:---------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------| +| 1.0.4 | 2023-03-15 | [23671](https://github.com/airbytehq/airbyte/pull/23671) | Add info about main permissions in spec and doc links in error message to navigate user | | 1.0.3 | 2023-03-14 | [24043](https://github.com/airbytehq/airbyte/pull/24043) | Do not emit incomplete records for `user_insights` stream | | 1.0.2 | 2023-03-14 | [24042](https://github.com/airbytehq/airbyte/pull/24042) | Test publish flow | | 1.0.1 | 2023-01-19 | [21602](https://github.com/airbytehq/airbyte/pull/21602) | Handle abnormally large state values |