Skip to content

Commit 0973b33

Browse files
Source Typeform: fix check connection authenticator loop (#8466)
* removed full forms list loop * better exception return * Update airbyte-integrations/connectors/source-typeform/source_typeform/source.py Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com> * added comments to show bug * better error handling with empty form list * rebase Co-authored-by: Marcos Marx <marcosmarxm@users.noreply.github.com> Co-authored-by: Marcos Marx <marcosmarxm@gmail.com>
1 parent aa67604 commit 0973b33

File tree

5 files changed

+26
-9
lines changed

5 files changed

+26
-9
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@
686686
- name: Typeform
687687
sourceDefinitionId: e7eff203-90bf-43e5-a240-19ea3056c474
688688
dockerRepository: airbyte/source-typeform
689-
dockerImageTag: 0.1.2
689+
dockerImageTag: 0.1.3
690690
documentationUrl: https://docs.airbyte.io/integrations/sources/typeform
691691
icon: typeform.svg
692692
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6354,7 +6354,7 @@
63546354
supportsDBT: false
63556355
supported_destination_sync_modes:
63566356
- "append"
6357-
- dockerImage: "airbyte/source-typeform:0.1.2"
6357+
- dockerImage: "airbyte/source-typeform:0.1.3"
63586358
spec:
63596359
documentationUrl: "https://docs.airbyte.io/integrations/sources/typeform"
63606360
connectionSpecification:

airbyte-integrations/connectors/source-typeform/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.1.2
15+
LABEL io.airbyte.version=0.1.3
1616
LABEL io.airbyte.name=airbyte/source-typeform

airbyte-integrations/connectors/source-typeform/source_typeform/source.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,30 @@ class SourceTypeform(AbstractSource):
202202
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, any]:
203203
try:
204204
form_ids = config.get("form_ids", []).copy()
205-
auth = TokenAuthenticator(token=config["token"])
206205
# verify if form inputted by user is valid
207-
for form in TrimForms(authenticator=auth, **config).read_records(sync_mode=SyncMode.full_refresh):
208-
if form.get("id") in form_ids:
209-
form_ids.remove(form.get("id"))
206+
try:
207+
url = f"{TypeformStream.url_base}/me"
208+
auth_headers = {"Authorization": f"Bearer {config['token']}"}
209+
session = requests.get(url, headers=auth_headers)
210+
session.raise_for_status()
211+
except requests.exceptions.BaseHTTPError as e:
212+
return False, f"Cannot authenticate, please verify token. Error: {e}"
210213
if form_ids:
211-
return False, f"Cannot find forms with IDs: {form_ids}. Please make sure they are valid form IDs and try again."
212-
return True, None
214+
for form in form_ids:
215+
try:
216+
url = f"{TypeformStream.url_base}/forms/{form}"
217+
auth_headers = {"Authorization": f"Bearer {config['token']}"}
218+
response = requests.get(url, headers=auth_headers)
219+
response.raise_for_status()
220+
except requests.exceptions.BaseHTTPError as e:
221+
return (
222+
False,
223+
f"Cannot find forms with ID: {form}. Please make sure they are valid form IDs and try again. Error: {e}",
224+
)
225+
return True, None
226+
else:
227+
return True, None
228+
213229
except requests.exceptions.RequestException as e:
214230
return False, e
215231

docs/integrations/sources/typeform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ API rate limits \(2 requests per second\): [https://developer.typeform.com/get-s
6565

6666
| Version | Date | Pull Request | Subject |
6767
| :--- | :--- | :--- | :--- |
68+
| 0.1.3 | 2021-12-07 | [8466](https://github.com/airbytehq/airbyte/pull/8466) | Change Check Connection Function Logic |
6869
| 0.1.2 | 2021-10-11 | [6571](https://github.com/airbytehq/airbyte/pull/6571) | Support pulling data from a select set of forms |
6970
| 0.1.1 | 2021-09-06 | [5799](https://github.com/airbytehq/airbyte/pull/5799) | Add missed choices field to responses schema |
7071
| 0.1.0 | 2021-07-10 | [4541](https://github.com/airbytehq/airbyte/pull/4541) | Initial release for Typeform API supporting Forms and Responses streams |

0 commit comments

Comments
 (0)